├── .gitignore ├── .dockerignore ├── lib-gst-meet ├── src │ ├── xmpp │ │ ├── mod.rs │ │ ├── ns.rs │ │ ├── jitsi.rs │ │ ├── extdisco.rs │ │ └── connection.rs │ ├── stanza_filter.rs │ ├── source.rs │ ├── util.rs │ ├── lib.rs │ ├── pinger.rs │ ├── tls.rs │ └── colibri.rs ├── LICENSE-MIT ├── Cargo.toml └── LICENSE-APACHE ├── nice-gst-meet-sys ├── tests │ ├── manual.h │ ├── layout.c │ ├── constant.c │ └── abi.rs ├── Gir.toml ├── build.rs ├── LICENSE-MIT ├── Cargo.toml └── LICENSE-APACHE ├── Cargo.toml ├── jitsi-xmpp-parsers ├── src │ ├── lib.rs │ ├── ns.rs │ ├── helpers.rs │ ├── jingle_dtls_srtp.rs │ ├── jingle_ice_udp.rs │ ├── jingle_rtp.rs │ ├── jingle_ssma.rs │ └── jingle.rs └── Cargo.toml ├── lib-gst-meet-c ├── cbindgen.toml ├── Cargo.toml ├── include │ └── gstmeet.h └── src │ └── lib.rs ├── rustfmt.toml ├── nice-gst-meet ├── Gir.toml ├── src │ ├── lib.rs │ ├── flags.rs │ ├── candidate.rs │ └── enums.rs ├── LICENSE-MIT ├── Cargo.toml └── LICENSE-APACHE ├── Dockerfile ├── .github └── workflows │ └── rustdoc.yml ├── LICENSE-MIT ├── gst-meet ├── LICENSE-MIT ├── Cargo.toml ├── LICENSE-APACHE └── src │ └── main.rs ├── deny.toml ├── shell.nix ├── README.md └── LICENSE-APACHE /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | target 2 | -------------------------------------------------------------------------------- /lib-gst-meet/src/xmpp/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod connection; 2 | pub(crate) mod extdisco; 3 | pub(crate) mod jitsi; 4 | mod ns; 5 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | library = "Nice" 3 | version = "0.1" 4 | min_cfg_version = "0.1" 5 | work_mode = "sys" 6 | target_path = "." 7 | external_libraries = [] 8 | 9 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "2" 3 | members = [ 4 | "gst-meet", 5 | "lib-gst-meet", 6 | "lib-gst-meet-c", 7 | "nice-gst-meet", 8 | "nice-gst-meet-sys", 9 | "jitsi-xmpp-parsers", 10 | ] 11 | 12 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | mod macros; 3 | 4 | mod helpers; 5 | pub mod jingle; 6 | pub mod jingle_dtls_srtp; 7 | pub mod jingle_ice_udp; 8 | pub mod jingle_rtp; 9 | pub mod jingle_ssma; 10 | pub mod ns; 11 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/ns.rs: -------------------------------------------------------------------------------- 1 | /// Jitsi Meet general namespace 2 | pub const JITSI_MEET: &str = "http://jitsi.org/jitmeet"; 3 | 4 | /// Jitsi Meet Colibri namespace 5 | pub const JITSI_COLIBRI: &str = "http://jitsi.org/protocol/colibri"; 6 | -------------------------------------------------------------------------------- /lib-gst-meet/src/xmpp/ns.rs: -------------------------------------------------------------------------------- 1 | /// XEP-0215: External Service Discovery 2 | pub(crate) const EXTDISCO: &str = "urn:xmpp:extdisco:2"; 3 | 4 | pub(crate) const JITSI_FOCUS: &str = "http://jitsi.org/protocol/focus"; 5 | 6 | pub(crate) const JITSI_JITMEET: &str = "http://jitsi.org/jitmeet"; 7 | -------------------------------------------------------------------------------- /lib-gst-meet/src/stanza_filter.rs: -------------------------------------------------------------------------------- 1 | use anyhow::Result; 2 | use async_trait::async_trait; 3 | use xmpp_parsers::Element; 4 | 5 | #[async_trait] 6 | pub trait StanzaFilter { 7 | fn filter(&self, element: &Element) -> bool; 8 | async fn take(&self, element: Element) -> Result<()>; 9 | } 10 | -------------------------------------------------------------------------------- /lib-gst-meet-c/cbindgen.toml: -------------------------------------------------------------------------------- 1 | language = "C" 2 | include_guard = "gstmeet_h" 3 | autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" 4 | sys_includes = ["glib/glib.h", "gst/gst.h"] 5 | after_includes = "\ntypedef struct JitsiConnection JitsiConnection;\ntypedef struct JitsiConference JitsiConference;" -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | tab_spaces = 2 2 | use_field_init_shorthand = true 3 | use_try_shorthand = true 4 | control_brace_style = "ClosingNextLine" 5 | condense_wildcard_suffixes = true 6 | match_block_trailing_comma = true 7 | imports_granularity = "Crate" 8 | newline_style = "Unix" 9 | reorder_impl_items = true 10 | group_imports = "StdExternalCrate" 11 | style_edition = "2021" 12 | -------------------------------------------------------------------------------- /nice-gst-meet/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | library = "Nice" 3 | version = "0.1" 4 | min_cfg_version = "0.1" 5 | work_mode = "normal" 6 | auto_path = "src" 7 | target_path = "." 8 | external_libraries = [] 9 | generate = [ 10 | "Nice.Address", 11 | "Nice.Agent", 12 | "Nice.AgentOption", 13 | "Nice.Candidate", 14 | "Nice.CandidateTransport", 15 | "Nice.CandidateType", 16 | "Nice.Compatibility", 17 | "Nice.ComponentState", 18 | "Nice.RelayType", 19 | ] 20 | manual = ["glib.MainContext"] 21 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/build.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(feature = "dox"))] 6 | use std::process; 7 | 8 | #[cfg(feature = "dox")] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(feature = "dox"))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={}", s); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib-gst-meet/src/source.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Clone)] 2 | pub(crate) struct Source { 3 | pub(crate) ssrc: u32, 4 | pub(crate) participant_id: Option, 5 | pub(crate) media_type: MediaType, 6 | } 7 | 8 | #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] 9 | #[repr(C)] 10 | pub enum MediaType { 11 | Video, 12 | Audio, 13 | } 14 | 15 | impl MediaType { 16 | pub(crate) fn jitsi_muted_presence_element_name(&self) -> &'static str { 17 | match self { 18 | MediaType::Video => "videomuted", 19 | MediaType::Audio => "audiomuted", 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/library/alpine:3.20.0 AS builder 2 | RUN apk --no-cache --update upgrade --ignore alpine-baselayout \ 3 | && apk --no-cache add build-base gstreamer-dev gst-plugins-base-dev libnice-dev openssl-dev cargo cmake clang16-libclang rust-bindgen 4 | COPY . . 5 | RUN cargo build --release -p gst-meet 6 | 7 | FROM docker.io/library/alpine:3.20.0 8 | RUN apk --update --no-cache upgrade --ignore alpine-baselayout \ 9 | && apk --no-cache add openssl gstreamer gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav libnice libnice-gstreamer 10 | COPY --from=builder target/release/gst-meet /usr/local/bin 11 | ENTRYPOINT ["/usr/local/bin/gst-meet"] 12 | -------------------------------------------------------------------------------- /lib-gst-meet/src/util.rs: -------------------------------------------------------------------------------- 1 | use std::collections::hash_map::Entry; 2 | 3 | use uuid::Uuid; 4 | 5 | pub(crate) fn generate_id() -> String { 6 | Uuid::new_v4().to_string() 7 | } 8 | 9 | pub(crate) trait FallibleEntry<'a, V> { 10 | fn or_try_insert_with Result>(self, default: F) -> Result<&'a mut V, E>; 11 | } 12 | 13 | impl<'a, K, V> FallibleEntry<'a, V> for Entry<'a, K, V> { 14 | fn or_try_insert_with Result>(self, default: F) -> Result<&'a mut V, E> { 15 | Ok(match self { 16 | Entry::Occupied(entry) => entry.into_mut(), 17 | Entry::Vacant(entry) => entry.insert(default()?), 18 | }) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib-gst-meet/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod colibri; 2 | mod conference; 3 | mod jingle; 4 | mod pinger; 5 | mod source; 6 | mod stanza_filter; 7 | mod tls; 8 | mod util; 9 | mod xmpp; 10 | 11 | pub use xmpp_parsers; 12 | 13 | pub use crate::{ 14 | conference::{Feature, JitsiConference, JitsiConferenceConfig, Participant}, 15 | source::MediaType, 16 | stanza_filter::StanzaFilter, 17 | xmpp::connection::{Authentication, Connection}, 18 | }; 19 | 20 | #[cfg(feature = "tracing-subscriber")] 21 | pub fn init_tracing(level: tracing::Level) { 22 | tracing_subscriber::fmt() 23 | .with_max_level(level) 24 | .with_span_events(tracing_subscriber::fmt::format::FmtSpan::CLOSE) 25 | .with_target(false) 26 | .init(); 27 | } 28 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use xmpp_parsers::Error; 2 | 3 | /// Codec for colon-separated bytes of uppercase hexadecimal. 4 | pub struct ColonSeparatedHex; 5 | 6 | impl ColonSeparatedHex { 7 | pub fn decode(s: &str) -> Result, Error> { 8 | let mut bytes = vec![]; 9 | for i in 0..(1 + s.len()) / 3 { 10 | let byte = u8::from_str_radix(&s[3 * i..3 * i + 2], 16)?; 11 | if 3 * i + 2 < s.len() { 12 | assert_eq!(&s[3 * i + 2..3 * i + 3], ":"); 13 | } 14 | bytes.push(byte); 15 | } 16 | Ok(bytes) 17 | } 18 | 19 | pub fn encode(b: &[u8]) -> Option { 20 | let mut bytes = vec![]; 21 | for byte in b { 22 | bytes.push(format!("{:02X}", byte)); 23 | } 24 | Some(bytes.join(":")) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "jitsi-xmpp-parsers" 3 | description = "Provides types for non-standard XMPP elements used by Jitsi Meet" 4 | version = "0.2.0" 5 | edition = "2021" 6 | license = "MPL-2.0" 7 | readme = "../README.md" 8 | repository = "https://github.com/avstack/gst-meet" 9 | documentation = "https://docs.rs/jitsi-xmpp-parsers/" 10 | authors = ["Jasper Hugo "] 11 | 12 | [dependencies] 13 | jid = { version = "0.10", default-features = false, features = ["minidom"] } 14 | minidom = { version = "0.15", default-features = false } 15 | xmpp-parsers = { version = "0.20", default-features = false, features = ["disable-validation"] } 16 | 17 | [package.metadata.docs.rs] 18 | rustdoc-args = [ "--sort-modules-by-appearance", "-Zunstable-options" ] 19 | -------------------------------------------------------------------------------- /nice-gst-meet/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | mod agent; 6 | pub use self::agent::Agent; 7 | 8 | mod candidate; 9 | pub use self::candidate::Candidate; 10 | 11 | mod enums; 12 | pub use self::enums::{ 13 | CandidateTransport, CandidateType, Compatibility, ComponentState, RelayType, 14 | }; 15 | 16 | mod flags; 17 | use nice_sys as ffi; 18 | 19 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 20 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 21 | pub use self::flags::AgentOption; 22 | 23 | pub fn debug_enable(with_stun: bool) { 24 | unsafe { 25 | ffi::nice_debug_enable(with_stun as i32); 26 | } 27 | } 28 | 29 | pub fn debug_disable(with_stun: bool) { 30 | unsafe { 31 | ffi::nice_debug_disable(with_stun as i32); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib-gst-meet-c/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lib-gst-meet-c" 3 | description = "Connect GStreamer pipelines to Jitsi Meet conferences (C bindings)" 4 | version = "0.1.0" 5 | edition = "2018" 6 | license = "MIT/Apache-2.0" 7 | authors = ["Jasper Hugo "] 8 | 9 | [dependencies] 10 | anyhow = { version = "1", default-features = false } 11 | glib = { version = "0.19", default-features = false } 12 | gstreamer = { version = "0.22", default-features = false } 13 | lib-gst-meet = { version = "0.8", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] } 14 | tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] } 15 | tracing = { version = "0.1", default-features = false } 16 | 17 | [lib] 18 | name = "gstmeet" 19 | crate-type = ["staticlib", "cdylib"] 20 | 21 | [features] 22 | default = [] 23 | log-rtp = ["lib-gst-meet/log-rtp"] 24 | -------------------------------------------------------------------------------- /.github/workflows/rustdoc.yml: -------------------------------------------------------------------------------- 1 | name: Deploy docs to GitHub Pages 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | rustdoc: 8 | name: Deploy Documentation 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Install dependencies 12 | run: sudo apt -y install libglib2.0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev libnice-dev 13 | - name: Check out 14 | uses: actions/checkout@v1 15 | - name: Install Rust toolchain 16 | uses: actions-rs/toolchain@v1 17 | with: 18 | toolchain: stable 19 | profile: minimal 20 | override: true 21 | components: rustfmt, rust-src 22 | - name: Build docs 23 | uses: actions-rs/cargo@v1 24 | with: 25 | command: doc 26 | args: --all --no-deps 27 | - name: Deploy docs to GitHub Pages 28 | uses: peaceiris/actions-gh-pages@v3 29 | with: 30 | github_token: ${{ secrets.GITHUB_TOKEN }} 31 | publish_dir: ./target/doc -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /gst-meet/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /lib-gst-meet/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /nice-gst-meet/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /nice-gst-meet-sys/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | [advisories] 2 | db-path = "~/.cargo/advisory-db" 3 | db-urls = ["https://github.com/rustsec/advisory-db"] 4 | vulnerability = "deny" 5 | unmaintained = "deny" 6 | yanked = "deny" 7 | notice = "deny" 8 | ignore = [] 9 | 10 | [licenses] 11 | unlicensed = "deny" 12 | allow = ["MPL-2.0"] 13 | deny = [] 14 | copyleft = "deny" 15 | allow-osi-fsf-free = "either" 16 | default = "deny" 17 | confidence-threshold = 1.0 18 | exceptions = [] 19 | 20 | [[licenses.clarify]] 21 | name = "ring" 22 | version = "*" 23 | expression = "MIT AND ISC AND OpenSSL" 24 | license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] 25 | 26 | [[licenses.clarify]] 27 | name = "webpki" 28 | version = "*" 29 | expression = "ISC" 30 | license-files = [{ path = "LICENSE", hash = 0x001c7e6c }] 31 | 32 | [bans] 33 | multiple-versions = "deny" 34 | wildcards = "deny" 35 | highlight = "all" 36 | allow = [] 37 | deny = [] 38 | skip = [] 39 | skip-tree = [ 40 | { name = "paste", version = "0.1.18", depth = 2 } 41 | ] 42 | 43 | [sources] 44 | unknown-registry = "deny" 45 | unknown-git = "deny" 46 | allow-registry = ["https://github.com/rust-lang/crates.io-index"] 47 | -------------------------------------------------------------------------------- /nice-gst-meet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nice-gst-meet" 3 | description = "Bindings to libnice for gst-meet" 4 | version = "0.3.0" 5 | edition = "2018" 6 | license = "MIT/Apache-2.0" 7 | authors = ["Jasper Hugo "] 8 | 9 | [dependencies] 10 | bitflags = { version = "2", default-features = false, optional = true } 11 | glib = { version = "0.19", default-features = false } 12 | libc = { version = "0.2", default-features = false } 13 | nice-gst-meet-sys = { version = "0.3", path = "../nice-gst-meet-sys", default-features = false } 14 | nix = { version = "0.28", default-features = false, features = ["socket", "net"] } 15 | 16 | [features] 17 | v0_1_4 = ["nice-gst-meet-sys/v0_1_4"] 18 | v0_1_5 = ["nice-gst-meet-sys/v0_1_5", "v0_1_4"] 19 | v0_1_6 = ["nice-gst-meet-sys/v0_1_6", "v0_1_5"] 20 | v0_1_8 = ["nice-gst-meet-sys/v0_1_8", "v0_1_6"] 21 | v0_1_14 = ["nice-gst-meet-sys/v0_1_14", "v0_1_8"] 22 | v0_1_15 = ["nice-gst-meet-sys/v0_1_15", "v0_1_14", "bitflags"] 23 | v0_1_16 = ["nice-gst-meet-sys/v0_1_16", "v0_1_15"] 24 | v0_1_17 = ["nice-gst-meet-sys/v0_1_17", "v0_1_16"] 25 | v0_1_18 = ["nice-gst-meet-sys/v0_1_18", "v0_1_17"] 26 | v0_1_20 = ["nice-gst-meet-sys/v0_1_20", "v0_1_18"] 27 | dox = [] 28 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | let 3 | libnice-patched = libnice.overrideAttrs(old: rec { 4 | buildInputs = [ 5 | gst_all_1.gstreamer 6 | gst_all_1.gst-plugins-base 7 | openssl 8 | ]; 9 | outputs = [ "bin" "out" "dev" ]; 10 | mesonFlags = old.mesonFlags ++ ["-Dgupnp=disabled" "-Dgtk_doc=disabled"]; 11 | meta.platforms = lib.platforms.unix; 12 | }); 13 | gst-plugins-bad-patched = gst_all_1.gst-plugins-bad.override { 14 | faacSupport = true; 15 | }; 16 | gst-plugins-ugly-patched = gst_all_1.gst-plugins-ugly.overrideAttrs(old: rec { 17 | buildInputs = lib.lists.subtractLists [a52dec] old.buildInputs; 18 | mesonFlags = old.mesonFlags ++ ["-Da52dec=disabled"]; 19 | }); 20 | in 21 | mkShell { 22 | name = "gst-meet"; 23 | buildInputs = [ 24 | cargo 25 | pkg-config 26 | git 27 | cacert 28 | openssl 29 | glib 30 | glib-networking 31 | gst_all_1.gstreamer 32 | gst_all_1.gst-plugins-base 33 | gst_all_1.gst-plugins-good 34 | gst-plugins-bad-patched 35 | gst-plugins-ugly-patched 36 | libnice-patched 37 | ] ++ (if stdenv.isDarwin then [ 38 | darwin.apple_sdk.frameworks.AppKit 39 | darwin.apple_sdk.frameworks.Security 40 | ] else []); 41 | 42 | GIO_EXTRA_MODULES = ["${pkgs.glib-networking.out}/lib/gio/modules"]; 43 | } 44 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/jingle_dtls_srtp.rs: -------------------------------------------------------------------------------- 1 | use xmpp_parsers::{ 2 | hashes::{Algo, Hash}, 3 | jingle_dtls_srtp::Setup, 4 | ns::JINGLE_DTLS, 5 | Error, 6 | }; 7 | 8 | use crate::helpers::ColonSeparatedHex; 9 | 10 | generate_element!( 11 | /// Fingerprint of the key used for a DTLS handshake. 12 | Fingerprint, "fingerprint", JINGLE_DTLS, 13 | attributes: [ 14 | /// The hash algorithm used for this fingerprint. 15 | hash: Required = "hash", 16 | 17 | /// Indicates which of the end points should initiate the TCP connection establishment. 18 | setup: Option = "setup" 19 | ], 20 | text: ( 21 | /// Hash value of this fingerprint. 22 | value: ColonSeparatedHex> 23 | ) 24 | ); 25 | 26 | impl Fingerprint { 27 | /// Create a new Fingerprint from a Setup and a Hash. 28 | pub fn from_hash(setup: Setup, hash: Hash) -> Fingerprint { 29 | Fingerprint { 30 | hash: hash.algo, 31 | setup: Some(setup), 32 | value: hash.hash, 33 | } 34 | } 35 | 36 | /// Create a new Fingerprint from a Setup and parsing the hash. 37 | pub fn from_colon_separated_hex( 38 | setup: Setup, 39 | algo: &str, 40 | hash: &str, 41 | ) -> Result { 42 | let algo = algo.parse()?; 43 | let hash = Hash::from_colon_separated_hex(algo, hash)?; 44 | Ok(Fingerprint::from_hash(setup, hash)) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib-gst-meet/src/xmpp/jitsi.rs: -------------------------------------------------------------------------------- 1 | use std::{collections::HashMap, convert::TryFrom}; 2 | 3 | use anyhow::Result; 4 | use xmpp_parsers::{iq::IqSetPayload, Element}; 5 | 6 | use crate::xmpp::ns; 7 | 8 | pub(crate) struct Conference { 9 | pub(crate) machine_uid: String, 10 | pub(crate) room: String, 11 | pub(crate) properties: HashMap, 12 | } 13 | 14 | impl IqSetPayload for Conference {} 15 | 16 | impl TryFrom for Conference { 17 | type Error = anyhow::Error; 18 | 19 | fn try_from(_element: Element) -> Result { 20 | unimplemented!() 21 | } 22 | } 23 | 24 | impl From for Element { 25 | fn from(conference: Conference) -> Element { 26 | let mut builder = Element::builder("conference", ns::JITSI_FOCUS) 27 | .attr("machine-uid", conference.machine_uid) 28 | .attr("room", conference.room); 29 | for (name, value) in conference.properties { 30 | builder = builder.append( 31 | Element::builder("property", ns::JITSI_FOCUS) 32 | .attr("name", name) 33 | .attr("value", value) 34 | .build(), 35 | ); 36 | } 37 | builder.build() 38 | } 39 | } 40 | 41 | pub(crate) struct JsonMessage { 42 | pub(crate) payload: serde_json::Value, 43 | } 44 | 45 | impl TryFrom for Element { 46 | type Error = anyhow::Error; 47 | 48 | fn try_from(message: JsonMessage) -> Result { 49 | Ok( 50 | Element::builder("json-message", ns::JITSI_JITMEET) 51 | .append(serde_json::to_string(&message.payload)?) 52 | .build(), 53 | ) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /gst-meet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gst-meet" 3 | description = "A tool for connecting GStreamer pipelines to Jitsi Meet conferences" 4 | version = "0.5.0" 5 | edition = "2021" 6 | license = "MIT/Apache-2.0" 7 | authors = ["Jasper Hugo "] 8 | 9 | [dependencies] 10 | anyhow = { version = "1", default-features = false, features = ["std"] } 11 | colibri = { version = "0.1", default-features = false } 12 | futures = { version = "0.3", default-features = false } 13 | glib = { version = "0.19", default-features = false, features = ["log"] } 14 | gstreamer = { version = "0.22", default-features = false } 15 | http = { version = "1", default-features = false } 16 | lib-gst-meet = { version = "0.8", path = "../lib-gst-meet", default-features = false, features = ["tracing-subscriber"] } 17 | serde_urlencoded = { version = "0.7", default-features = false } 18 | structopt = { version = "0.3", default-features = false } 19 | tokio = { version = "1", default-features = false, features = ["macros", "rt-multi-thread", "signal", "sync", "time"] } 20 | tokio-stream = { version = "0.1", default-features = false } 21 | tracing = { version = "0.1", default-features = false, features = ["attributes", "std"] } 22 | 23 | [target.'cfg(target_os = "macos")'.dependencies] 24 | cocoa = { version = "0.25", default-features = false } 25 | 26 | [features] 27 | default = ["tls-rustls-native-roots"] 28 | log-rtp = ["lib-gst-meet/log-rtp"] 29 | tls-insecure = ["lib-gst-meet/tls-insecure"] 30 | tls-native = ["lib-gst-meet/tls-native"] 31 | tls-native-vendored = ["lib-gst-meet/tls-native-vendored"] 32 | tls-rustls-native-roots = ["lib-gst-meet/tls-rustls-native-roots"] 33 | tls-rustls-webpki-roots = ["lib-gst-meet/tls-rustls-webpki-roots"] 34 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/jingle_ice_udp.rs: -------------------------------------------------------------------------------- 1 | use xmpp_parsers::{ 2 | jingle_ice_udp::Candidate, 3 | ns::{JINGLE_DTLS, JINGLE_ICE_UDP}, 4 | }; 5 | 6 | use crate::{jingle_dtls_srtp::Fingerprint, ns::JITSI_COLIBRI}; 7 | 8 | generate_element!( 9 | /// Wrapper element for an ICE-UDP transport. 10 | #[derive(Default)] 11 | Transport, "transport", JINGLE_ICE_UDP, 12 | attributes: [ 13 | /// A Password as defined in ICE-CORE. 14 | pwd: Option = "pwd", 15 | 16 | /// A User Fragment as defined in ICE-CORE. 17 | ufrag: Option = "ufrag", 18 | ], 19 | children: [ 20 | /// List of candidates for this ICE-UDP session. 21 | candidates: Vec = ("candidate", JINGLE_ICE_UDP) => Candidate, 22 | 23 | /// Fingerprint of the key used for the DTLS handshake. 24 | fingerprint: Option = ("fingerprint", JINGLE_DTLS) => Fingerprint, 25 | 26 | /// Details of the Colibri WebSocket 27 | web_socket: Option = ("web-socket", JITSI_COLIBRI) => WebSocket 28 | ] 29 | ); 30 | 31 | impl Transport { 32 | /// Create a new ICE-UDP transport. 33 | pub fn new() -> Transport { 34 | Default::default() 35 | } 36 | 37 | /// Add a candidate to this transport. 38 | pub fn add_candidate(mut self, candidate: Candidate) -> Self { 39 | self.candidates.push(candidate); 40 | self 41 | } 42 | 43 | /// Set the DTLS-SRTP fingerprint of this transport. 44 | pub fn with_fingerprint(mut self, fingerprint: Fingerprint) -> Self { 45 | self.fingerprint = Some(fingerprint); 46 | self 47 | } 48 | } 49 | 50 | generate_element!( 51 | /// Colibri WebSocket details 52 | WebSocket, "web-socket", JITSI_COLIBRI, 53 | attributes: [ 54 | /// The WebSocket URL 55 | url: Required = "url", 56 | ] 57 | ); 58 | -------------------------------------------------------------------------------- /lib-gst-meet/src/pinger.rs: -------------------------------------------------------------------------------- 1 | use std::{convert::TryFrom, time::Duration}; 2 | 3 | use anyhow::{anyhow, Result}; 4 | use async_trait::async_trait; 5 | use tokio::{sync::mpsc, task::JoinHandle, time}; 6 | use tracing::warn; 7 | use xmpp_parsers::{iq::Iq, ping::Ping, Element, FullJid, Jid}; 8 | 9 | use crate::{stanza_filter::StanzaFilter, util::generate_id}; 10 | 11 | const PING_INTERVAL: Duration = Duration::from_secs(30); 12 | 13 | #[derive(Debug)] 14 | pub(crate) struct Pinger { 15 | pub(crate) jid: FullJid, 16 | pub(crate) tx: mpsc::Sender, 17 | pub(crate) ping_task: JoinHandle<()>, 18 | } 19 | 20 | impl Pinger { 21 | pub(crate) fn new(jid: FullJid, tx: mpsc::Sender) -> Pinger { 22 | let ping_tx = tx.clone(); 23 | let ping_task = tokio::spawn(async move { 24 | let mut interval = time::interval(PING_INTERVAL); 25 | // The first tick completes immediately. 26 | interval.tick().await; 27 | loop { 28 | interval.tick().await; 29 | if let Err(e) = ping_tx.send(Iq::from_get(generate_id(), Ping).into()).await { 30 | warn!("failed to send XMPP ping: {:?}", e); 31 | } 32 | } 33 | }); 34 | Pinger { jid, tx, ping_task } 35 | } 36 | } 37 | 38 | #[async_trait] 39 | impl StanzaFilter for Pinger { 40 | #[tracing::instrument(level = "trace")] 41 | fn filter(&self, element: &Element) -> bool { 42 | element.is("iq", "jabber:client") && element.has_child("ping", "urn:xmpp:ping") 43 | } 44 | 45 | #[tracing::instrument(level = "trace", err)] 46 | async fn take(&self, element: Element) -> Result<()> { 47 | let iq = Iq::try_from(element)?; 48 | let result_iq = Iq::empty_result( 49 | iq.from.ok_or_else(|| anyhow!("iq missing from"))?, 50 | iq.id.clone(), 51 | ) 52 | .with_from(Jid::Full(self.jid.clone())); 53 | self.tx.send(result_iq.into()).await?; 54 | Ok(()) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/jingle_rtp.rs: -------------------------------------------------------------------------------- 1 | use xmpp_parsers::{ 2 | jingle_rtcp_fb::RtcpFb, 3 | jingle_rtp::{PayloadType, RtcpMux}, 4 | jingle_rtp_hdrext::RtpHdrext, 5 | ns::{JINGLE_RTP, JINGLE_RTP_HDREXT, JINGLE_SSMA}, 6 | }; 7 | 8 | use crate::jingle_ssma::{Group, Source}; 9 | 10 | generate_element!( 11 | /// Wrapper element describing an RTP session. 12 | Description, "description", JINGLE_RTP, 13 | attributes: [ 14 | /// Namespace of the encryption scheme used. 15 | media: Required = "media", 16 | 17 | /// User-friendly name for the encryption scheme, should be `None` for OTR, 18 | /// legacy OpenPGP and OX. 19 | // XXX: is this a String or an u32?! Refer to RFC 3550. 20 | ssrc: Option = "ssrc", 21 | ], 22 | children: [ 23 | /// List of encodings that can be used for this RTP stream. 24 | payload_types: Vec = ("payload-type", JINGLE_RTP) => PayloadType, 25 | 26 | /// Specifies the ability to multiplex RTP Data and Control Packets on a single port as 27 | /// described in RFC 5761. 28 | rtcp_mux: Option = ("rtcp-mux", JINGLE_RTP) => RtcpMux, 29 | 30 | /// List of ssrc-group. 31 | ssrc_groups: Vec = ("ssrc-group", JINGLE_SSMA) => Group, 32 | 33 | /// List of ssrc. 34 | ssrcs: Vec = ("source", JINGLE_SSMA) => Source, 35 | 36 | /// List of header extensions. 37 | hdrexts: Vec = ("rtp-hdrext", JINGLE_RTP_HDREXT) => RtpHdrext 38 | 39 | // TODO: Add support for and . 40 | ] 41 | ); 42 | 43 | impl Description { 44 | /// Create a new RTP description. 45 | pub fn new(media: String) -> Description { 46 | Description { 47 | media, 48 | ssrc: None, 49 | payload_types: Vec::new(), 50 | rtcp_mux: None, 51 | ssrc_groups: Vec::new(), 52 | ssrcs: Vec::new(), 53 | hdrexts: Vec::new(), 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nice-gst-meet-sys" 3 | description = "FFI bindings to libnice for gst-meet" 4 | version = "0.3.0" 5 | links = "nice" 6 | edition = "2018" 7 | build = "build.rs" 8 | license = "MIT/Apache-2.0" 9 | authors = ["Jasper Hugo "] 10 | 11 | [package.metadata.system-deps.nice] 12 | name = "nice" 13 | version = "0.1" 14 | 15 | [package.metadata.system-deps.nice.v0_1_4] 16 | version = "0.1.4" 17 | 18 | [package.metadata.system-deps.nice.v0_1_5] 19 | version = "0.1.5" 20 | 21 | [package.metadata.system-deps.nice.v0_1_6] 22 | version = "0.1.6" 23 | 24 | [package.metadata.system-deps.nice.v0_1_8] 25 | version = "0.1.8" 26 | 27 | [package.metadata.system-deps.nice.v0_1_14] 28 | version = "0.1.14" 29 | 30 | [package.metadata.system-deps.nice.v0_1_15] 31 | version = "0.1.15" 32 | 33 | [package.metadata.system-deps.nice.v0_1_16] 34 | version = "0.1.16" 35 | 36 | [package.metadata.system-deps.nice.v0_1_17] 37 | version = "0.1.17" 38 | 39 | [package.metadata.system-deps.nice.v0_1_18] 40 | version = "0.1.18" 41 | 42 | [package.metadata.system-deps.nice.v0_1_20] 43 | version = "0.1.20" 44 | 45 | [package.metadata.docs.rs] 46 | features = ["dox"] 47 | 48 | [lib] 49 | name = "nice_sys" 50 | 51 | [dependencies] 52 | libc = { version = "0.2", default-features = false } 53 | glib = { version = "0.19", default-features = false } 54 | gio = { version = "0.19", default-features = false } 55 | gobject-sys = { version = "0.19", default-features = false } 56 | 57 | [build-dependencies] 58 | system-deps = { version = "6", default-features = false } 59 | 60 | [dev-dependencies] 61 | shell-words = { version = "1", default-features = false } 62 | tempfile = { version = "3", default-features = false } 63 | 64 | [features] 65 | v0_1_4 = [] 66 | v0_1_5 = ["v0_1_4"] 67 | v0_1_6 = ["v0_1_5"] 68 | v0_1_8 = ["v0_1_6"] 69 | v0_1_14 = ["v0_1_8"] 70 | v0_1_15 = ["v0_1_14"] 71 | v0_1_16 = ["v0_1_15"] 72 | v0_1_17 = ["v0_1_16"] 73 | v0_1_18 = ["v0_1_17"] 74 | v0_1_20 = ["v0_1_18"] 75 | dox = [] 76 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/tests/layout.c: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | #include "manual.h" 6 | #include 7 | #include 8 | 9 | int main() { 10 | printf("%s;%zu;%zu\n", "NiceAddress", sizeof(NiceAddress), alignof(NiceAddress)); 11 | printf("%s;%zu;%zu\n", "NiceAgentClass", sizeof(NiceAgentClass), alignof(NiceAgentClass)); 12 | printf("%s;%zu;%zu\n", "NiceAgentOption", sizeof(NiceAgentOption), alignof(NiceAgentOption)); 13 | printf("%s;%zu;%zu\n", "NiceCandidate", sizeof(NiceCandidate), alignof(NiceCandidate)); 14 | printf("%s;%zu;%zu\n", "NiceCandidateTransport", sizeof(NiceCandidateTransport), alignof(NiceCandidateTransport)); 15 | printf("%s;%zu;%zu\n", "NiceCandidateType", sizeof(NiceCandidateType), alignof(NiceCandidateType)); 16 | printf("%s;%zu;%zu\n", "NiceCompatibility", sizeof(NiceCompatibility), alignof(NiceCompatibility)); 17 | printf("%s;%zu;%zu\n", "NiceComponentState", sizeof(NiceComponentState), alignof(NiceComponentState)); 18 | printf("%s;%zu;%zu\n", "NiceComponentType", sizeof(NiceComponentType), alignof(NiceComponentType)); 19 | printf("%s;%zu;%zu\n", "NiceInputMessage", sizeof(NiceInputMessage), alignof(NiceInputMessage)); 20 | printf("%s;%zu;%zu\n", "NiceNominationMode", sizeof(NiceNominationMode), alignof(NiceNominationMode)); 21 | printf("%s;%zu;%zu\n", "NiceOutputMessage", sizeof(NiceOutputMessage), alignof(NiceOutputMessage)); 22 | printf("%s;%zu;%zu\n", "NiceProxyType", sizeof(NiceProxyType), alignof(NiceProxyType)); 23 | printf("%s;%zu;%zu\n", "NiceRelayType", sizeof(NiceRelayType), alignof(NiceRelayType)); 24 | printf("%s;%zu;%zu\n", "PseudoTcpCallbacks", sizeof(PseudoTcpCallbacks), alignof(PseudoTcpCallbacks)); 25 | printf("%s;%zu;%zu\n", "PseudoTcpDebugLevel", sizeof(PseudoTcpDebugLevel), alignof(PseudoTcpDebugLevel)); 26 | printf("%s;%zu;%zu\n", "PseudoTcpShutdown", sizeof(PseudoTcpShutdown), alignof(PseudoTcpShutdown)); 27 | printf("%s;%zu;%zu\n", "PseudoTcpState", sizeof(PseudoTcpState), alignof(PseudoTcpState)); 28 | printf("%s;%zu;%zu\n", "PseudoTcpWriteResult", sizeof(PseudoTcpWriteResult), alignof(PseudoTcpWriteResult)); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /lib-gst-meet/src/xmpp/extdisco.rs: -------------------------------------------------------------------------------- 1 | use std::convert::TryFrom; 2 | 3 | use anyhow::{bail, Context, Result}; 4 | use xmpp_parsers::{iq::IqGetPayload, Element}; 5 | 6 | use crate::xmpp::ns; 7 | 8 | #[derive(Debug)] 9 | pub(crate) struct ServicesQuery {} 10 | 11 | impl TryFrom for ServicesQuery { 12 | type Error = anyhow::Error; 13 | 14 | fn try_from(_elem: Element) -> Result { 15 | unimplemented!() 16 | } 17 | } 18 | 19 | impl From for Element { 20 | fn from(_services: ServicesQuery) -> Element { 21 | let builder = Element::builder("services", ns::EXTDISCO); 22 | builder.build() 23 | } 24 | } 25 | 26 | impl IqGetPayload for ServicesQuery {} 27 | 28 | #[derive(Debug, Clone)] 29 | pub struct Service { 30 | pub(crate) r#type: String, 31 | pub(crate) name: Option, 32 | pub(crate) host: String, 33 | pub(crate) port: Option, 34 | pub(crate) transport: Option, 35 | pub(crate) restricted: Option, 36 | pub(crate) username: Option, 37 | pub(crate) password: Option, 38 | pub(crate) expires: Option, 39 | } 40 | 41 | #[derive(Debug)] 42 | pub(crate) struct ServicesResult { 43 | pub(crate) services: Vec, 44 | } 45 | 46 | impl TryFrom for ServicesResult { 47 | type Error = anyhow::Error; 48 | 49 | fn try_from(elem: Element) -> Result { 50 | if !elem.is("services", ns::EXTDISCO) { 51 | bail!("not a services element"); 52 | } 53 | Ok(ServicesResult { 54 | services: elem 55 | .children() 56 | .map(|child| { 57 | Ok(Service { 58 | r#type: child.attr("type").context("missing type attr")?.to_owned(), 59 | name: child.attr("name").map(ToOwned::to_owned), 60 | host: child.attr("host").context("missing host attr")?.to_owned(), 61 | port: child.attr("port").map(|p| p.parse()).transpose()?, 62 | transport: child.attr("transport").map(ToOwned::to_owned), 63 | restricted: child 64 | .attr("restricted") 65 | .map(|b| b.to_lowercase() == "parse" || b == "1"), 66 | username: child.attr("username").map(ToOwned::to_owned), 67 | password: child.attr("password").map(ToOwned::to_owned), 68 | expires: child.attr("expires").map(ToOwned::to_owned), 69 | }) 70 | }) 71 | .collect::>()?, 72 | }) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /nice-gst-meet/src/flags.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 6 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 7 | use std::fmt; 8 | 9 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 10 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 11 | use bitflags::bitflags; 12 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 13 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 14 | use glib::translate::*; 15 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 16 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 17 | use nice_sys as ffi; 18 | 19 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 20 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 21 | bitflags! { 22 | #[doc(alias = "NiceAgentOption")] 23 | #[derive(Debug)] 24 | pub struct AgentOption: u32 { 25 | #[doc(alias = "NICE_AGENT_OPTION_REGULAR_NOMINATION")] 26 | const REGULAR_NOMINATION = ffi::NICE_AGENT_OPTION_REGULAR_NOMINATION as u32; 27 | #[doc(alias = "NICE_AGENT_OPTION_RELIABLE")] 28 | const RELIABLE = ffi::NICE_AGENT_OPTION_RELIABLE as u32; 29 | #[doc(alias = "NICE_AGENT_OPTION_LITE_MODE")] 30 | const LITE_MODE = ffi::NICE_AGENT_OPTION_LITE_MODE as u32; 31 | #[doc(alias = "NICE_AGENT_OPTION_ICE_TRICKLE")] 32 | const ICE_TRICKLE = ffi::NICE_AGENT_OPTION_ICE_TRICKLE as u32; 33 | #[doc(alias = "NICE_AGENT_OPTION_SUPPORT_RENOMINATION")] 34 | const SUPPORT_RENOMINATION = ffi::NICE_AGENT_OPTION_SUPPORT_RENOMINATION as u32; 35 | #[doc(alias = "NICE_AGENT_OPTION_CONSENT_FRESHNESS")] 36 | const CONSENT_FRESHNESS = ffi::NICE_AGENT_OPTION_CONSENT_FRESHNESS as u32; 37 | } 38 | } 39 | 40 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 41 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 42 | impl fmt::Display for AgentOption { 43 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 44 | ::fmt(self, f) 45 | } 46 | } 47 | 48 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 49 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 50 | #[doc(hidden)] 51 | impl IntoGlib for AgentOption { 52 | type GlibType = ffi::NiceAgentOption; 53 | 54 | fn into_glib(self) -> ffi::NiceAgentOption { 55 | self.bits() 56 | } 57 | } 58 | 59 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 60 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 61 | #[doc(hidden)] 62 | impl FromGlib for AgentOption { 63 | unsafe fn from_glib(value: ffi::NiceAgentOption) -> Self { 64 | Self::from_bits_truncate(value) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/jingle_ssma.rs: -------------------------------------------------------------------------------- 1 | use minidom::{Element, NSChoice::Any}; 2 | use xmpp_parsers::{jingle_ssma::Semantics, ns::JINGLE_SSMA}; 3 | 4 | use crate::ns::JITSI_MEET; 5 | 6 | generate_element!( 7 | /// Source element for the ssrc SDP attribute. 8 | Source, "source", JINGLE_SSMA, 9 | attributes: [ 10 | /// Maps to the ssrc-id parameter. 11 | id: Required = "ssrc", 12 | 13 | name: Option = "name", 14 | video_type: Option = "videoType", 15 | ], 16 | children: [ 17 | /// List of attributes for this source. 18 | // The namespace should be JINGLE_SSMA, but we have to use Any because Jicofo produces 19 | // parameters with the wrong namespace. 20 | // https://github.com/jitsi/jitsi-xmpp-extensions/issues/81 21 | parameters: Vec = ("parameter", Any) => Parameter, 22 | 23 | /// --- Non-standard attributes used by Jitsi Meet: --- 24 | 25 | /// ssrc-info for this source. 26 | info: Option = ("ssrc-info", JITSI_MEET) => SsrcInfo 27 | ] 28 | ); 29 | 30 | impl Source { 31 | /// Create a new SSMA Source element. 32 | pub fn new(id: u32, name: Option, video_type: Option) -> Source { 33 | Source { 34 | id, 35 | name, 36 | video_type, 37 | parameters: Vec::new(), 38 | info: None, 39 | } 40 | } 41 | } 42 | 43 | /// Parameter associated with a ssrc. 44 | #[derive(Debug, Clone, PartialEq)] 45 | pub struct Parameter { 46 | pub name: String, 47 | pub value: Option, 48 | } 49 | 50 | impl TryFrom for Parameter { 51 | type Error = xmpp_parsers::Error; 52 | 53 | fn try_from(root: Element) -> Result { 54 | // The namespace should be JINGLE_SSMA, but we have to use Any because Jicofo produces 55 | // parameters with the wrong namespace. 56 | // https://github.com/jitsi/jitsi-xmpp-extensions/issues/81 57 | check_self!(root, "parameter", Any, "Parameter"); 58 | Ok(Parameter { 59 | name: get_attr!(root, "name", Required), 60 | value: get_attr!(root, "value", Option), 61 | }) 62 | } 63 | } 64 | 65 | impl From for Element { 66 | fn from(parameter: Parameter) -> Element { 67 | Element::builder("parameter", JINGLE_SSMA) 68 | .attr("name", parameter.name) 69 | .attr("value", parameter.value) 70 | .build() 71 | } 72 | } 73 | 74 | generate_element!( 75 | /// ssrc-info associated with a ssrc. 76 | SsrcInfo, "ssrc-info", JITSI_MEET, 77 | attributes: [ 78 | /// The owner of the ssrc. 79 | owner: Required = "owner" 80 | ] 81 | ); 82 | 83 | generate_element!( 84 | /// Element grouping multiple ssrc. 85 | Group, "ssrc-group", JINGLE_SSMA, 86 | attributes: [ 87 | /// The semantics of this group. 88 | semantics: Required = "semantics", 89 | ], 90 | children: [ 91 | /// The various ssrc concerned by this group. 92 | sources: Vec = ("source", JINGLE_SSMA) => Source 93 | ] 94 | ); 95 | -------------------------------------------------------------------------------- /lib-gst-meet-c/include/gstmeet.h: -------------------------------------------------------------------------------- 1 | #ifndef gstmeet_h 2 | #define gstmeet_h 3 | 4 | /* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | typedef struct JitsiConnection JitsiConnection; 14 | typedef struct JitsiConference JitsiConference; 15 | 16 | typedef struct Context Context; 17 | 18 | typedef struct ConferenceConfig { 19 | const char *muc; 20 | const char *focus; 21 | const char *nick; 22 | const char *region; 23 | const char *video_codec; 24 | } ConferenceConfig; 25 | 26 | typedef struct Participant { 27 | const char *jid; 28 | const char *muc_jid; 29 | const char *nick; 30 | } Participant; 31 | 32 | typedef enum {VIDEO, AUDIO} MediaType; 33 | 34 | struct Context *gstmeet_init(void); 35 | 36 | void gstmeet_init_tracing(const char *level); 37 | 38 | void gstmeet_deinit(struct Context *context); 39 | 40 | JitsiConnection *gstmeet_connection_new(struct Context *context, 41 | const char *websocket_url, 42 | const char *xmpp_domain, 43 | bool tls_insecure); 44 | 45 | void gstmeet_connection_free(JitsiConnection *connection); 46 | 47 | bool gstmeet_connection_connect(struct Context *context, JitsiConnection *connection); 48 | 49 | JitsiConference *gstmeet_connection_join_conference(struct Context *context, 50 | JitsiConnection *connection, 51 | GMainContext *glib_main_context, 52 | const struct ConferenceConfig *config); 53 | 54 | bool gstmeet_conference_connected(struct Context *context, JitsiConference *conference); 55 | 56 | bool gstmeet_conference_leave(struct Context *context, JitsiConference *conference); 57 | 58 | bool gstmeet_conference_set_muted(struct Context *context, 59 | JitsiConference *conference, 60 | MediaType media_type, 61 | bool muted); 62 | 63 | GstPipeline *gstmeet_conference_pipeline(struct Context *context, JitsiConference *conference); 64 | 65 | GstElement *gstmeet_conference_audio_sink_element(struct Context *context, 66 | JitsiConference *conference); 67 | 68 | GstElement *gstmeet_conference_video_sink_element(struct Context *context, 69 | JitsiConference *conference); 70 | 71 | void gstmeet_conference_on_participant(struct Context *context, 72 | JitsiConference *conference, 73 | GstBin *(*f)(struct Participant, void *), 74 | void *callback_context); 75 | 76 | bool gstmeet_conference_set_pipeline_state(struct Context *context, 77 | JitsiConference *conference, 78 | GstState state); 79 | 80 | #endif /* gstmeet_h */ 81 | -------------------------------------------------------------------------------- /lib-gst-meet/src/tls.rs: -------------------------------------------------------------------------------- 1 | #[cfg(any( 2 | feature = "tls-rustls-native-roots", 3 | feature = "tls-rustls-webpki-roots" 4 | ))] 5 | use std::sync::Arc; 6 | 7 | #[cfg(not(feature = "tls-insecure"))] 8 | use anyhow::bail; 9 | use anyhow::{Context, Result}; 10 | use tokio_tungstenite::Connector; 11 | 12 | #[cfg(feature = "tls-rustls-native-roots")] 13 | pub(crate) fn wss_connector(insecure: bool) -> Result { 14 | let mut roots = rustls::RootCertStore::empty(); 15 | for cert in 16 | rustls_native_certs::load_native_certs().context("failed to load native root certs")? 17 | { 18 | roots.add(cert).context("failed to add native root certs")?; 19 | } 20 | 21 | let mut config = rustls::ClientConfig::builder() 22 | .with_root_certificates(roots) 23 | .with_no_client_auth(); 24 | #[cfg(feature = "tls-insecure")] 25 | if insecure { 26 | config 27 | .dangerous() 28 | .set_certificate_verifier(Arc::new(InsecureServerCertVerifier)); 29 | } 30 | #[cfg(not(feature = "tls-insecure"))] 31 | if insecure { 32 | bail!( 33 | "Insecure TLS mode can only be enabled if the tls-insecure feature was enabled at compile time." 34 | ) 35 | } 36 | Ok(Connector::Rustls(Arc::new(config))) 37 | } 38 | 39 | #[cfg(feature = "tls-rustls-webpki-roots")] 40 | pub(crate) fn wss_connector(insecure: bool) -> Result { 41 | let mut roots = rustls::RootCertStore::empty(); 42 | roots.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| { 43 | rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( 44 | ta.subject, 45 | ta.spki, 46 | ta.name_constraints, 47 | ) 48 | })); 49 | 50 | let config = rustls::ClientConfig::builder() 51 | .with_root_certificates(roots) 52 | .with_no_client_auth(); 53 | #[cfg(feature = "tls-insecure")] 54 | if insecure { 55 | config 56 | .dangerous() 57 | .set_certificate_verifier(Arc::new(InsecureServerCertVerifier)); 58 | } 59 | #[cfg(not(feature = "tls-insecure"))] 60 | if insecure { 61 | bail!( 62 | "Insecure TLS mode can only be enabled if the tls-insecure feature was enabled at compile time." 63 | ) 64 | } 65 | Ok(Connector::Rustls(Arc::new(config))) 66 | } 67 | 68 | #[cfg(any(feature = "tls-native", feature = "tls-native-vendored"))] 69 | pub(crate) fn wss_connector(insecure: bool) -> Result { 70 | let mut builder = native_tls::TlsConnector::builder(); 71 | builder.min_protocol_version(Some(native_tls::Protocol::Tlsv12)); 72 | #[cfg(feature = "tls-insecure")] 73 | if insecure { 74 | builder.danger_accept_invalid_certs(true); 75 | builder.danger_accept_invalid_hostnames(true); 76 | } 77 | #[cfg(not(feature = "tls-insecure"))] 78 | if insecure { 79 | bail!( 80 | "Insecure TLS mode can only be enabled if the tls-insecure feature was enabled at compile time." 81 | ) 82 | } 83 | Ok(Connector::NativeTls( 84 | builder 85 | .build() 86 | .context("failed to build native TLS connector")?, 87 | )) 88 | } 89 | 90 | #[cfg(all( 91 | feature = "tls-insecure", 92 | any( 93 | feature = "tls-rustls-native-roots", 94 | feature = "tls-rustls-webpki-roots" 95 | ) 96 | ))] 97 | struct InsecureServerCertVerifier; 98 | 99 | #[cfg(all( 100 | feature = "tls-insecure", 101 | any( 102 | feature = "tls-rustls-native-roots", 103 | feature = "tls-rustls-webpki-roots" 104 | ) 105 | ))] 106 | impl rustls::client::ServerCertVerifier for InsecureServerCertVerifier { 107 | fn verify_server_cert( 108 | &self, 109 | _end_entity: &rustls::Certificate, 110 | _intermediates: &[rustls::Certificate], 111 | _server_name: &rustls::ServerName, 112 | _scts: &mut dyn Iterator, 113 | _ocsp_response: &[u8], 114 | _now: std::time::SystemTime, 115 | ) -> Result { 116 | Ok(rustls::client::ServerCertVerified::assertion()) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /lib-gst-meet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lib-gst-meet" 3 | description = "Connect GStreamer pipelines to Jitsi Meet conferences" 4 | version = "0.8.0" 5 | edition = "2021" 6 | license = "MIT/Apache-2.0" 7 | readme = "../README.md" 8 | repository = "https://github.com/avstack/gst-meet" 9 | documentation = "https://docs.rs/lib-gst-meet/" 10 | authors = ["Jasper Hugo "] 11 | 12 | [dependencies] 13 | anyhow = { version = "1", default-features = false, features = ["std"] } 14 | async-stream = { version = "0.3", default-features = false } 15 | async-trait = { version = "0.1", default-features = false } 16 | base64 = { version = "0.22", default-features = false } 17 | bytes = { version = "1", default-features = false, features = ["std"] } 18 | colibri = { version = "0.1", default-features = false } 19 | futures = { version = "0.3", default-features = false } 20 | glib = { version = "0.19", default-features = false } 21 | gstreamer = { version = "0.22", default-features = false, features = ["v1_20"] } 22 | gstreamer-rtp = { version = "0.22", default-features = false, features = ["v1_20"] } 23 | hex = { version = "0.4", default-features = false, features = ["std"] } 24 | itertools = { version = "0.13", default-features = false, features = ["use_std"] } 25 | jid = { version = "0.10", default-features = false } 26 | jitsi-xmpp-parsers = { version = "0.2", path = "../jitsi-xmpp-parsers", default-features = false } 27 | libc = { version = "0.2", default-features = false } 28 | maplit = { version = "1", default-features = false } 29 | native-tls = { version = "0.2", default-features = false, optional = true } 30 | nice-gst-meet = { version = "0.3", path = "../nice-gst-meet", default-features = false, features = ["v0_1_18"] } 31 | once_cell = { version = "1", default-features = false, features = ["std"] } 32 | rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] } 33 | rcgen = { version = "0.13", default-features = false, features = ["crypto", "pem", "aws_lc_rs"] } 34 | ring = { version = "0.17", default-features = false } 35 | rtcp = { version = "0.11", default-features = false, optional = true } 36 | rustls = { version = "0.22", default-features = false, features = ["logging", "tls12", "aws_lc_rs"], optional = true } 37 | rustls-native-certs = { version = "0.7", default-features = false, optional = true } 38 | serde = { version = "1", default-features = false, features = ["derive"] } 39 | serde_json = { version = "1", default-features = false, features = ["std"] } 40 | sha2 = { version = "0.10", default-features = false, features = ["std"] } 41 | syntect = { version = "5", optional = true } 42 | tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "macros", "sync", "time"] } 43 | tokio-stream = { version = "0.1", default-features = false, features = ["time"] } 44 | tokio-tungstenite = { version = "0.21", default-features = false, features = ["connect"] } 45 | tracing = { version = "0.1", default-features = false, features = ["attributes", "std"] } 46 | tracing-subscriber = { version = "0.3", optional = true, default-features = false, features = [ 47 | "fmt", 48 | "registry", 49 | "smallvec", 50 | "parking_lot", 51 | "tracing-log", 52 | ] } 53 | uuid = { version = "1", default-features = false, features = ["v4"] } 54 | webpki-roots = { version = "0.26", default-features = false, optional = true } 55 | xmpp-parsers = { version = "0.20", default-features = false, features = ["disable-validation"] } 56 | 57 | [features] 58 | # Ideally we would enable rustls/dangerous_configuration only when tls-insecure is enabled, but until weak-dep-features is stabilised, that 59 | # would cause rustls to always be pulled in. 60 | default = ["tls-rustls-native-roots"] 61 | log-rtp = ["rtcp"] 62 | syntax-highlighting = ["syntect"] 63 | tls-insecure = [] 64 | tls-native = ["tokio-tungstenite/native-tls", "native-tls"] 65 | tls-native-vendored = ["tokio-tungstenite/native-tls-vendored", "native-tls/vendored"] 66 | tls-rustls-native-roots = ["tokio-tungstenite/rustls-tls-native-roots", "rustls", "rustls-native-certs"] 67 | tls-rustls-webpki-roots = ["tokio-tungstenite/rustls-tls-webpki-roots", "rustls", "webpki-roots"] 68 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/tests/constant.c: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | #include "manual.h" 6 | #include 7 | 8 | #define PRINT_CONSTANT(CONSTANT_NAME) \ 9 | printf("%s;", #CONSTANT_NAME); \ 10 | printf(_Generic((CONSTANT_NAME), \ 11 | char *: "%s", \ 12 | const char *: "%s", \ 13 | char: "%c", \ 14 | signed char: "%hhd", \ 15 | unsigned char: "%hhu", \ 16 | short int: "%hd", \ 17 | unsigned short int: "%hu", \ 18 | int: "%d", \ 19 | unsigned int: "%u", \ 20 | long: "%ld", \ 21 | unsigned long: "%lu", \ 22 | long long: "%lld", \ 23 | unsigned long long: "%llu", \ 24 | float: "%f", \ 25 | double: "%f", \ 26 | long double: "%ld"), \ 27 | CONSTANT_NAME); \ 28 | printf("\n"); 29 | 30 | int main() { 31 | PRINT_CONSTANT(NICE_AGENT_MAX_REMOTE_CANDIDATES); 32 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_CONSENT_FRESHNESS); 33 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_ICE_TRICKLE); 34 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_LITE_MODE); 35 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_REGULAR_NOMINATION); 36 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_RELIABLE); 37 | PRINT_CONSTANT((guint) NICE_AGENT_OPTION_SUPPORT_RENOMINATION); 38 | PRINT_CONSTANT(NICE_CANDIDATE_MAX_FOUNDATION); 39 | PRINT_CONSTANT(NICE_CANDIDATE_MAX_LOCAL_ADDRESSES); 40 | PRINT_CONSTANT(NICE_CANDIDATE_MAX_TURN_SERVERS); 41 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE); 42 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE); 43 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TRANSPORT_TCP_SO); 44 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TRANSPORT_UDP); 45 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TYPE_HOST); 46 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TYPE_PEER_REFLEXIVE); 47 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TYPE_RELAYED); 48 | PRINT_CONSTANT((gint) NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE); 49 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_DRAFT19); 50 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_GOOGLE); 51 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_LAST); 52 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_MSN); 53 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_OC2007); 54 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_OC2007R2); 55 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_RFC5245); 56 | PRINT_CONSTANT((gint) NICE_COMPATIBILITY_WLM2009); 57 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_CONNECTED); 58 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_CONNECTING); 59 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_DISCONNECTED); 60 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_FAILED); 61 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_GATHERING); 62 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_LAST); 63 | PRINT_CONSTANT((gint) NICE_COMPONENT_STATE_READY); 64 | PRINT_CONSTANT((gint) NICE_COMPONENT_TYPE_RTCP); 65 | PRINT_CONSTANT((gint) NICE_COMPONENT_TYPE_RTP); 66 | PRINT_CONSTANT((gint) NICE_NOMINATION_MODE_AGGRESSIVE); 67 | PRINT_CONSTANT((gint) NICE_NOMINATION_MODE_REGULAR); 68 | PRINT_CONSTANT((gint) NICE_PROXY_TYPE_HTTP); 69 | PRINT_CONSTANT((gint) NICE_PROXY_TYPE_LAST); 70 | PRINT_CONSTANT((gint) NICE_PROXY_TYPE_NONE); 71 | PRINT_CONSTANT((gint) NICE_PROXY_TYPE_SOCKS5); 72 | PRINT_CONSTANT((gint) NICE_RELAY_TYPE_TURN_TCP); 73 | PRINT_CONSTANT((gint) NICE_RELAY_TYPE_TURN_TLS); 74 | PRINT_CONSTANT((gint) NICE_RELAY_TYPE_TURN_UDP); 75 | PRINT_CONSTANT((gint) PSEUDO_TCP_CLOSED); 76 | PRINT_CONSTANT((gint) PSEUDO_TCP_CLOSE_WAIT); 77 | PRINT_CONSTANT((gint) PSEUDO_TCP_CLOSING); 78 | PRINT_CONSTANT((gint) PSEUDO_TCP_DEBUG_NONE); 79 | PRINT_CONSTANT((gint) PSEUDO_TCP_DEBUG_NORMAL); 80 | PRINT_CONSTANT((gint) PSEUDO_TCP_DEBUG_VERBOSE); 81 | PRINT_CONSTANT((gint) PSEUDO_TCP_ESTABLISHED); 82 | PRINT_CONSTANT((gint) PSEUDO_TCP_FIN_WAIT_1); 83 | PRINT_CONSTANT((gint) PSEUDO_TCP_FIN_WAIT_2); 84 | PRINT_CONSTANT((gint) PSEUDO_TCP_LAST_ACK); 85 | PRINT_CONSTANT((gint) PSEUDO_TCP_LISTEN); 86 | PRINT_CONSTANT((gint) PSEUDO_TCP_SHUTDOWN_RD); 87 | PRINT_CONSTANT((gint) PSEUDO_TCP_SHUTDOWN_RDWR); 88 | PRINT_CONSTANT((gint) PSEUDO_TCP_SHUTDOWN_WR); 89 | PRINT_CONSTANT((gint) PSEUDO_TCP_SYN_RECEIVED); 90 | PRINT_CONSTANT((gint) PSEUDO_TCP_SYN_SENT); 91 | PRINT_CONSTANT((gint) PSEUDO_TCP_TIME_WAIT); 92 | PRINT_CONSTANT((gint) WR_FAIL); 93 | PRINT_CONSTANT((gint) WR_SUCCESS); 94 | PRINT_CONSTANT((gint) WR_TOO_LARGE); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /lib-gst-meet/src/colibri.rs: -------------------------------------------------------------------------------- 1 | use std::{sync::Arc, time::Duration}; 2 | 3 | use anyhow::{Context, Result}; 4 | use colibri::ColibriMessage; 5 | use futures::{ 6 | sink::SinkExt, 7 | stream::{StreamExt, TryStreamExt}, 8 | }; 9 | use rand::{thread_rng, RngCore}; 10 | use tokio::{ 11 | sync::{mpsc, Mutex}, 12 | time::sleep, 13 | }; 14 | use tokio_stream::wrappers::ReceiverStream; 15 | use tokio_tungstenite::tungstenite::{ 16 | http::{Request, Uri}, 17 | Message, 18 | }; 19 | use tracing::{debug, error, info, warn}; 20 | 21 | use crate::tls::wss_connector; 22 | 23 | const MAX_CONNECT_RETRIES: u8 = 3; 24 | const CONNECT_RETRY_SLEEP: Duration = Duration::from_secs(3); 25 | 26 | #[derive(Clone)] 27 | pub(crate) struct ColibriChannel { 28 | send_tx: mpsc::Sender, 29 | recv_tx: Arc>>>, 30 | } 31 | 32 | impl ColibriChannel { 33 | pub(crate) async fn new(uri: &str, tls_insecure: bool) -> Result { 34 | let uri: Uri = uri.parse()?; 35 | let host = uri.host().context("invalid WebSocket URL: missing host")?; 36 | 37 | let mut retries = 0; 38 | let colibri_websocket = loop { 39 | let mut key = [0u8; 16]; 40 | thread_rng().fill_bytes(&mut key); 41 | let request = Request::get(&uri) 42 | .header("sec-websocket-key", base64::encode(&key)) 43 | .header("sec-websocket-version", "13") 44 | .header("host", host) 45 | // TODO: the server should probably not enforce this since non-browser clients are now possible 46 | .header("origin", format!("https://{}", host)) 47 | .header("connection", "Upgrade") 48 | .header("upgrade", "websocket") 49 | .body(())?; 50 | match tokio_tungstenite::connect_async_tls_with_config( 51 | request, 52 | None, 53 | true, 54 | Some(wss_connector(tls_insecure).context("failed to build TLS connector")?), 55 | ) 56 | .await 57 | { 58 | Ok((websocket, _)) => break websocket, 59 | Err(e) => { 60 | if retries < MAX_CONNECT_RETRIES { 61 | warn!("Failed to connect Colibri WebSocket, will retry: {:?}", e); 62 | sleep(CONNECT_RETRY_SLEEP).await; 63 | retries += 1; 64 | } 65 | else { 66 | return Err(e).context("Failed to connect Colibri WebSocket"); 67 | } 68 | }, 69 | } 70 | }; 71 | 72 | info!("Connected Colibri WebSocket"); 73 | 74 | let (mut colibri_sink, mut colibri_stream) = colibri_websocket.split(); 75 | let recv_tx: Arc>>> = Arc::new(Mutex::new(vec![])); 76 | let recv_task = { 77 | let recv_tx = recv_tx.clone(); 78 | tokio::spawn(async move { 79 | while let Some(msg) = colibri_stream.try_next().await? { 80 | match msg { 81 | Message::Text(text) => { 82 | debug!("Colibri <<< {}", text); 83 | match serde_json::from_str::(&text) { 84 | Ok(colibri_msg) => { 85 | let mut txs = recv_tx.lock().await; 86 | let txs_clone = txs.clone(); 87 | for (i, tx) in txs_clone.iter().enumerate().rev() { 88 | if tx.send(colibri_msg.clone()).await.is_err() { 89 | debug!("colibri subscriber closed, removing"); 90 | txs.remove(i); 91 | } 92 | } 93 | }, 94 | Err(e) => warn!( 95 | "failed to parse frame on colibri websocket: {:?}\nframe: {}", 96 | e, text 97 | ), 98 | } 99 | }, 100 | Message::Binary(data) => debug!( 101 | "received unexpected {} byte binary frame on colibri websocket", 102 | data.len() 103 | ), 104 | Message::Close(_) => { 105 | debug!("received close frame on colibri websocket"); 106 | // TODO reconnect 107 | break; 108 | }, 109 | Message::Frame(_) | Message::Ping(_) | Message::Pong(_) => {}, // handled automatically by tungstenite 110 | } 111 | } 112 | Ok::<_, anyhow::Error>(()) 113 | }) 114 | }; 115 | 116 | let (send_tx, send_rx) = mpsc::channel(8); 117 | let send_task = tokio::spawn(async move { 118 | let mut stream = ReceiverStream::new(send_rx); 119 | while let Some(colibri_msg) = stream.next().await { 120 | match serde_json::to_string(&colibri_msg) { 121 | Ok(json) => { 122 | debug!("Colibri >>> {}", json); 123 | let msg = Message::Text(json); 124 | colibri_sink.send(msg).await?; 125 | }, 126 | Err(e) => warn!("failed to serialise colibri message: {:?}", e), 127 | } 128 | } 129 | Ok::<_, anyhow::Error>(()) 130 | }); 131 | 132 | tokio::spawn(async move { 133 | tokio::select! { 134 | res = recv_task => if let Ok(Err(e)) = res { 135 | error!("colibri recv loop: {:?}", e); 136 | }, 137 | res = send_task => if let Ok(Err(e)) = res { 138 | error!("colibri send loop: {:?}", e); 139 | }, 140 | }; 141 | }); 142 | 143 | Ok(Self { send_tx, recv_tx }) 144 | } 145 | 146 | pub(crate) async fn subscribe(&self, tx: mpsc::Sender) { 147 | self.recv_tx.lock().await.push(tx); 148 | } 149 | 150 | pub(crate) async fn send(&self, msg: ColibriMessage) -> Result<()> { 151 | self.send_tx.send(msg).await?; 152 | Ok(()) 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /nice-gst-meet/src/candidate.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | use std::{ 6 | ffi::CStr, 7 | net::{SocketAddr, SocketAddrV4, SocketAddrV6}, 8 | }; 9 | 10 | use glib::translate::*; 11 | use libc::c_char; 12 | use nice_sys as ffi; 13 | use nix::sys::socket::{AddressFamily, SockaddrStorage}; 14 | 15 | #[cfg(any(feature = "v0_1_18", feature = "dox"))] 16 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_18")))] 17 | use crate::CandidateTransport; 18 | use crate::CandidateType; 19 | 20 | glib::wrapper! { 21 | #[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] 22 | pub struct Candidate(Boxed); 23 | 24 | match fn { 25 | copy => |ptr| ffi::nice_candidate_copy(ptr), 26 | free => |ptr| ffi::nice_candidate_free(ptr), 27 | type_ => || ffi::nice_candidate_get_type(), 28 | } 29 | } 30 | 31 | impl ::std::fmt::Debug for Candidate { 32 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 33 | f.debug_struct("Candidate") 34 | .field("type_", &self.type_()) 35 | .field("foundation", &self.foundation()) 36 | .field("addr", &self.addr()) 37 | .field("priority", &self.priority()) 38 | .field("stream_id", &self.stream_id()) 39 | .field("component_id", &self.component_id()) 40 | .field("username", &self.username()) 41 | .field("password", &self.password()) 42 | .finish() 43 | } 44 | } 45 | 46 | unsafe impl Send for Candidate {} 47 | 48 | impl Candidate { 49 | #[doc(alias = "nice_candidate_new")] 50 | pub fn new(type_: CandidateType) -> Candidate { 51 | unsafe { from_glib_full(ffi::nice_candidate_new(type_.into_glib())) } 52 | } 53 | 54 | pub fn type_(&self) -> CandidateType { 55 | unsafe { CandidateType::from_glib(self.inner.type_) } 56 | } 57 | 58 | #[cfg(any(feature = "v0_1_18", feature = "dox"))] 59 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_18")))] 60 | pub fn transport(&self) -> CandidateTransport { 61 | unsafe { CandidateTransport::from_glib(self.inner.transport) } 62 | } 63 | 64 | #[cfg(any(feature = "v0_1_18", feature = "dox"))] 65 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_18")))] 66 | pub fn set_transport(&mut self, transport: CandidateTransport) { 67 | self.inner.transport = transport.into_glib(); 68 | } 69 | 70 | pub fn addr(&self) -> SocketAddr { 71 | unsafe { 72 | match AddressFamily::from_i32(self.inner.addr.s.addr.sa_family as i32).unwrap() { 73 | AddressFamily::Inet => SocketAddrV4::new( 74 | self.inner.addr.s.ip4.sin_addr.s_addr.into(), 75 | self.inner.addr.s.ip4.sin_port, 76 | ) 77 | .into(), 78 | AddressFamily::Inet6 => SocketAddrV6::new( 79 | self.inner.addr.s.ip6.sin6_addr.s6_addr.into(), 80 | self.inner.addr.s.ip6.sin6_port, 81 | self.inner.addr.s.ip6.sin6_flowinfo, 82 | self.inner.addr.s.ip6.sin6_scope_id, 83 | ) 84 | .into(), 85 | other => panic!("unsupported address family: {:?}", other), 86 | } 87 | } 88 | } 89 | 90 | pub fn set_addr(&mut self, addr: SocketAddr) { 91 | let sockaddr = SockaddrStorage::from(addr); 92 | if let Some(v4) = sockaddr.as_sockaddr_in() { 93 | unsafe { 94 | ffi::nice_address_set_ipv4(&mut self.inner.addr as *mut _, v4.ip().into()); 95 | ffi::nice_address_set_port(&mut self.inner.addr as *mut _, v4.port() as u32); 96 | } 97 | } 98 | else if let Some(v6) = sockaddr.as_sockaddr_in6() { 99 | unsafe { 100 | ffi::nice_address_set_ipv6(&mut self.inner.addr as *mut _, v6.ip().octets().as_ptr()); 101 | ffi::nice_address_set_port(&mut self.inner.addr as *mut _, v6.port() as u32); 102 | } 103 | } 104 | else { 105 | panic!("unsupported address family"); 106 | } 107 | } 108 | 109 | pub fn priority(&self) -> u32 { 110 | self.inner.priority 111 | } 112 | 113 | pub fn set_priority(&mut self, priority: u32) { 114 | self.inner.priority = priority; 115 | } 116 | 117 | pub fn stream_id(&self) -> u32 { 118 | self.inner.stream_id 119 | } 120 | 121 | pub fn set_stream_id(&mut self, stream_id: u32) { 122 | self.inner.stream_id = stream_id; 123 | } 124 | 125 | pub fn component_id(&self) -> u32 { 126 | self.inner.component_id 127 | } 128 | 129 | pub fn set_component_id(&mut self, component_id: u32) { 130 | self.inner.component_id = component_id; 131 | } 132 | 133 | pub fn foundation(&self) -> Result<&str, std::str::Utf8Error> { 134 | unsafe { CStr::from_ptr(&self.inner.foundation as *const c_char).to_str() } 135 | } 136 | 137 | pub fn set_foundation(&mut self, foundation: &str) { 138 | let mut bytes: Vec<_> = foundation 139 | .as_bytes() 140 | .iter() 141 | .take(32) 142 | .map(|c| *c as c_char) 143 | .collect(); 144 | bytes.resize(33, 0); 145 | self.inner.foundation.copy_from_slice(&bytes); 146 | } 147 | 148 | pub fn username(&self) -> Result<&str, std::str::Utf8Error> { 149 | if self.inner.username.is_null() { 150 | Ok("") 151 | } 152 | else { 153 | unsafe { CStr::from_ptr(self.inner.username).to_str() } 154 | } 155 | } 156 | 157 | pub fn set_username(&mut self, username: &str) { 158 | self.inner.username = username.to_owned().to_glib_full(); 159 | } 160 | 161 | pub fn password(&self) -> Result<&str, std::str::Utf8Error> { 162 | if self.inner.password.is_null() { 163 | Ok("") 164 | } 165 | else { 166 | unsafe { CStr::from_ptr(self.inner.password).to_str() } 167 | } 168 | } 169 | 170 | pub fn set_password(&mut self, password: &str) { 171 | self.inner.password = password.to_owned().to_glib_full(); 172 | } 173 | 174 | #[cfg(any(feature = "v0_1_15", feature = "dox"))] 175 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_15")))] 176 | #[doc(alias = "nice_candidate_equal_target")] 177 | pub fn equal_target(&self, candidate2: &Candidate) -> bool { 178 | unsafe { 179 | from_glib(ffi::nice_candidate_equal_target( 180 | self.to_glib_none().0, 181 | candidate2.to_glib_none().0, 182 | )) 183 | } 184 | } 185 | 186 | #[cfg(any(feature = "v0_1_18", feature = "dox"))] 187 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_18")))] 188 | #[doc(alias = "nice_candidate_transport_to_string")] 189 | pub fn transport_to_string(transport: CandidateTransport) -> Option { 190 | unsafe { 191 | from_glib_none(ffi::nice_candidate_transport_to_string( 192 | transport.into_glib(), 193 | )) 194 | } 195 | } 196 | 197 | #[cfg(any(feature = "v0_1_18", feature = "dox"))] 198 | #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_1_18")))] 199 | #[doc(alias = "nice_candidate_type_to_string")] 200 | pub fn type_to_string(type_: CandidateType) -> Option { 201 | unsafe { from_glib_none(ffi::nice_candidate_type_to_string(type_.into_glib())) } 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /lib-gst-meet-c/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | ffi::{c_void, CStr, CString}, 3 | os::raw::c_char, 4 | ptr, 5 | sync::{ 6 | atomic::{AtomicPtr, Ordering}, 7 | Arc, 8 | }, 9 | }; 10 | 11 | use anyhow::Result; 12 | use glib::{ 13 | ffi::GMainContext, 14 | translate::{from_glib, from_glib_full, ToGlibPtr}, 15 | }; 16 | use lib_gst_meet::JitsiConferenceConfig; 17 | pub use lib_gst_meet::{init_tracing, Authentication, Connection, JitsiConference, MediaType}; 18 | use tokio::runtime::Runtime; 19 | 20 | pub struct Context { 21 | runtime: Runtime, 22 | } 23 | 24 | #[repr(C)] 25 | pub struct ConferenceConfig { 26 | pub muc: *const c_char, 27 | pub focus: *const c_char, 28 | pub nick: *const c_char, 29 | pub region: *const c_char, 30 | pub video_codec: *const c_char, 31 | } 32 | 33 | #[repr(C)] 34 | pub struct Participant { 35 | pub jid: *const c_char, 36 | pub muc_jid: *const c_char, 37 | pub nick: *const c_char, 38 | } 39 | 40 | trait ResultExt { 41 | fn ok_raw_or_log(self) -> *mut T; 42 | } 43 | 44 | impl ResultExt for Result { 45 | fn ok_raw_or_log(self) -> *mut T { 46 | match self { 47 | Ok(o) => Box::into_raw(Box::new(o)), 48 | Err(e) => { 49 | eprintln!("lib-gst-meet: {:?}", e); 50 | ptr::null_mut() 51 | }, 52 | } 53 | } 54 | } 55 | 56 | #[no_mangle] 57 | pub extern "C" fn gstmeet_init() -> *mut Context { 58 | Runtime::new() 59 | .map(|runtime| Context { runtime }) 60 | .map_err(|e| e.into()) 61 | .ok_raw_or_log() 62 | } 63 | 64 | #[no_mangle] 65 | pub unsafe extern "C" fn gstmeet_init_tracing(level: *const c_char) { 66 | let level = CStr::from_ptr(level) 67 | .to_string_lossy() 68 | .parse() 69 | .expect("invalid tracing level"); 70 | init_tracing(level); 71 | } 72 | 73 | #[no_mangle] 74 | pub unsafe extern "C" fn gstmeet_deinit(context: *mut Context) { 75 | let _ = Box::from_raw(context); 76 | } 77 | 78 | #[no_mangle] 79 | pub unsafe extern "C" fn gstmeet_connection_new( 80 | context: *mut Context, 81 | websocket_url: *const c_char, 82 | xmpp_domain: *const c_char, 83 | room_name: *const c_char, 84 | tls_insecure: bool, 85 | ) -> *mut Connection { 86 | let websocket_url = CStr::from_ptr(websocket_url); 87 | let xmpp_domain = CStr::from_ptr(xmpp_domain); 88 | let room_name = CStr::from_ptr(room_name); 89 | (*context) 90 | .runtime 91 | .block_on(Connection::new( 92 | &websocket_url.to_string_lossy(), 93 | &xmpp_domain.to_string_lossy(), 94 | Authentication::Anonymous, 95 | &room_name.to_string_lossy(), 96 | tls_insecure, 97 | )) 98 | .map(|(connection, background)| { 99 | (*context).runtime.spawn(background); 100 | connection 101 | }) 102 | .ok_raw_or_log() 103 | } 104 | 105 | #[no_mangle] 106 | pub unsafe extern "C" fn gstmeet_connection_free(connection: *mut Connection) { 107 | let _ = Box::from_raw(connection); 108 | } 109 | 110 | #[no_mangle] 111 | pub unsafe extern "C" fn gstmeet_connection_connect( 112 | context: *mut Context, 113 | connection: *mut Connection, 114 | ) -> bool { 115 | (*context) 116 | .runtime 117 | .block_on((*connection).connect()) 118 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 119 | .is_ok() 120 | } 121 | 122 | #[no_mangle] 123 | pub unsafe extern "C" fn gstmeet_connection_join_conference( 124 | context: *mut Context, 125 | connection: *mut Connection, 126 | glib_main_context: *mut GMainContext, 127 | config: *const ConferenceConfig, 128 | ) -> *mut JitsiConference { 129 | let muc = match CStr::from_ptr((*config).muc).to_string_lossy().parse() { 130 | Ok(jid) => jid, 131 | Err(e) => { 132 | eprintln!("lib-gst-meet: invalid MUC JID: {:?}", e); 133 | return ptr::null_mut(); 134 | }, 135 | }; 136 | let focus = match CStr::from_ptr((*config).focus).to_string_lossy().parse() { 137 | Ok(jid) => jid, 138 | Err(e) => { 139 | eprintln!("lib-gst-meet: invalid focus JID: {:?}", e); 140 | return ptr::null_mut(); 141 | }, 142 | }; 143 | let region = if (*config).region.is_null() { 144 | None 145 | } 146 | else { 147 | Some( 148 | CStr::from_ptr((*config).region) 149 | .to_string_lossy() 150 | .to_string(), 151 | ) 152 | }; 153 | let config = JitsiConferenceConfig { 154 | muc, 155 | focus, 156 | nick: CStr::from_ptr((*config).nick).to_string_lossy().to_string(), 157 | region, 158 | video_codec: CStr::from_ptr((*config).video_codec) 159 | .to_string_lossy() 160 | .to_string(), 161 | extra_muc_features: vec![], 162 | 163 | // TODO 164 | start_bitrate: 800, 165 | stereo: false, 166 | 167 | recv_video_scale_width: 1280, 168 | recv_video_scale_height: 720, 169 | 170 | buffer_size: 200, 171 | 172 | #[cfg(feature = "log-rtp")] 173 | log_rtp: false, 174 | #[cfg(feature = "log-rtp")] 175 | log_rtcp: false, 176 | }; 177 | (*context) 178 | .runtime 179 | .block_on(JitsiConference::join( 180 | (*connection).clone(), 181 | from_glib_full(glib_main_context), 182 | config, 183 | )) 184 | .ok_raw_or_log() 185 | } 186 | 187 | #[no_mangle] 188 | pub unsafe extern "C" fn gstmeet_conference_leave( 189 | context: *mut Context, 190 | conference: *mut JitsiConference, 191 | ) -> bool { 192 | (*context) 193 | .runtime 194 | .block_on(Box::from_raw(conference).leave()) 195 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 196 | .is_ok() 197 | } 198 | 199 | #[no_mangle] 200 | pub unsafe extern "C" fn gstmeet_conference_set_muted( 201 | context: *mut Context, 202 | conference: *mut JitsiConference, 203 | media_type: MediaType, 204 | muted: bool, 205 | ) -> bool { 206 | (*context) 207 | .runtime 208 | .block_on((*conference).set_muted(media_type, muted)) 209 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 210 | .is_ok() 211 | } 212 | 213 | #[no_mangle] 214 | pub unsafe extern "C" fn gstmeet_conference_pipeline( 215 | context: *mut Context, 216 | conference: *mut JitsiConference, 217 | ) -> *mut gstreamer::ffi::GstPipeline { 218 | (*context) 219 | .runtime 220 | .block_on((*conference).pipeline()) 221 | .map(|pipeline| pipeline.to_glib_full()) 222 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 223 | .unwrap_or(ptr::null_mut()) 224 | } 225 | 226 | #[no_mangle] 227 | pub unsafe extern "C" fn gstmeet_conference_audio_sink_element( 228 | context: *mut Context, 229 | conference: *mut JitsiConference, 230 | ) -> *mut gstreamer::ffi::GstElement { 231 | (*context) 232 | .runtime 233 | .block_on((*conference).audio_sink_element()) 234 | .map(|pipeline| pipeline.to_glib_full()) 235 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 236 | .unwrap_or(ptr::null_mut()) 237 | } 238 | 239 | #[no_mangle] 240 | pub unsafe extern "C" fn gstmeet_conference_video_sink_element( 241 | context: *mut Context, 242 | conference: *mut JitsiConference, 243 | ) -> *mut gstreamer::ffi::GstElement { 244 | (*context) 245 | .runtime 246 | .block_on((*conference).video_sink_element()) 247 | .map(|pipeline| pipeline.to_glib_full()) 248 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 249 | .unwrap_or(ptr::null_mut()) 250 | } 251 | 252 | #[no_mangle] 253 | pub unsafe extern "C" fn gstmeet_conference_on_participant( 254 | context: *mut Context, 255 | conference: *mut JitsiConference, 256 | f: unsafe extern "C" fn( 257 | *mut JitsiConference, 258 | Participant, 259 | *mut c_void, 260 | ) -> *mut gstreamer::ffi::GstBin, 261 | ctx: *mut c_void, 262 | ) { 263 | let ctx = Arc::new(AtomicPtr::new(ctx)); 264 | (*context).runtime.block_on( 265 | (*conference).on_participant(move |conference, participant| { 266 | let ctx = ctx.clone(); 267 | Box::pin(async move { 268 | let participant = Participant { 269 | jid: participant 270 | .jid 271 | .map( 272 | |jid| Ok::<_, anyhow::Error>(CString::new(jid.to_string())?.into_raw() as *const _), 273 | ) 274 | .transpose()? 275 | .unwrap_or_else(ptr::null), 276 | muc_jid: CString::new(participant.muc_jid.to_string())?.into_raw() as *const _, 277 | nick: participant 278 | .nick 279 | .map(|nick| Ok::<_, anyhow::Error>(CString::new(nick)?.into_raw() as *const _)) 280 | .transpose()? 281 | .unwrap_or_else(ptr::null), 282 | }; 283 | f( 284 | Box::into_raw(Box::new(conference)), 285 | participant, 286 | ctx.load(Ordering::Relaxed), 287 | ); 288 | Ok(()) 289 | }) 290 | }), 291 | ); 292 | } 293 | 294 | #[no_mangle] 295 | pub unsafe extern "C" fn gstmeet_conference_set_pipeline_state( 296 | context: *mut Context, 297 | conference: *mut JitsiConference, 298 | state: gstreamer::ffi::GstState, 299 | ) -> bool { 300 | (*context) 301 | .runtime 302 | .block_on((*conference).set_pipeline_state(from_glib(state))) 303 | .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) 304 | .is_ok() 305 | } 306 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gst-meet: Integrate Jitsi Meet conferences with GStreamer pipelines 2 | 3 | Note: gst-meet is in an **alpha** state and is under active development. The command-line options and the lib-gst-meet API are subject to change. 4 | 5 | gst-meet provides a library and tool for integrating Jitsi Meet conferences with GStreamer pipelines. You can pipe audio and video into a conference as a participant, and pipe out other participants' audio and video streams. 6 | 7 | Thanks to GStreamer's flexibility and wide range of plugins, this enables many new possibilities. 8 | 9 | ## Dependencies 10 | 11 | * `gstreamer` >= 1.20 (latest version is recommended) 12 | * `gst-plugins-good`, `gst-plugins-bad` (same version as `gstreamer`) and any other plugins that you want to use in your pipelines 13 | * `glib` 14 | * `libnice` 15 | 16 | ### For building: 17 | 18 | * `pkg-config` 19 | * A Rust toolchain ([rustup](https://rustup.rs/) is the easiest way to install one) 20 | 21 | ## Building the development version 22 | 23 | Install the dependencies described above, along with their `-dev` packages if your distribution uses them. 24 | 25 | Check out the repository and then use `cargo` to build: 26 | 27 | ``` 28 | cargo build --release 29 | ``` 30 | 31 | The `gst-meet` binary can be found in `target/release`. 32 | 33 | ## Installing the latest release from crates.io 34 | 35 | ``` 36 | cargo install --force gst-meet 37 | ``` 38 | 39 | (`--force` will upgrade `gst-meet` if you have already installed it.) 40 | 41 | ## Docker 42 | 43 | A `Dockerfile` is provided that produces an Alpine 3.18.2 image with `gst-meet` installed in `/usr/local/bin`. 44 | 45 | ## Nix 46 | 47 | For nix users, a `shell.nix` is provided. Within the repository, run `nix-shell --pure` to get a shell with access to all needed dependencies (and nothing else). Proceed with `cargo build --release`. 48 | 49 | ## Library 50 | 51 | To integrate gst-meet into your own application, add a Cargo dependency on `lib-gst-meet`. 52 | 53 | ## Usage 54 | 55 | You can pass GStreamer pipeline fragments to the `gst-meet` tool. 56 | 57 | `--send-pipeline` is for sending audio and video. If it contains an element named `audio`, this audio will be streamed to the conference. The audio codec must be 48kHz Opus. If it contains an element named `video`, this video will be streamed to the conference. The video codec must match the codec passed to `--video-codec`, which is VP9 by default. 58 | 59 | `--recv-pipeline` is for receiving audio and video, if you want a single pipeline to handle all participants. If it contains an element named `audio`, a sink pad is requested on that element for each new participant, and decoded audio is sent to that pad. Similarly, if it contains an element named `video`, a sink pad is requred on that element for each new participant, and decoded & scaled video is sent to that pad. 60 | 61 | `--recv-pipeline-participant-template` is for receiving audio and video, if you want a separate pipeline for each participant. This pipeline will be created once for each other participant in the conference. If it contains an element named `audio`, the participant's decoded audio will be sent to that element. If it contains an element named `video`, the participant's decoded & scaled video will be sent to that element. The strings `{jid}`, `{jid_user}`, `{participant_id}` and `{nick}` are replaced in the template with the participant's full JID, user part, MUC JID resource part (a.k.a. participant/occupant ID) and nickname respectively. 62 | 63 | You can use `--recv-pipeline` and `--recv-pipeline-participant-template` together, for example to handle all the audio with a single `audiomixer` element but handle each video stream separately. If an `audio` or `video` element is found in both `--recv-pipeline` and `--recv-pipeline-participant-template`, then the one in `--recv-pipeline` is used. 64 | 65 | ## Examples 66 | 67 | A few examples of `gst-meet` usage are below. The GStreamer reference provides full details on available pipeline elements. 68 | 69 | `gst-meet --help` lists full usage information. 70 | 71 | Stream an Opus audio file to the conference. This is very efficient; the Opus data in the file is streamed directly without transcoding: 72 | 73 | ``` 74 | gst-meet --web-socket-url=wss://your.jitsi.domain/xmpp-websocket \ 75 | --room-name=roomname \ 76 | --send-pipeline="filesrc location=sample.opus ! queue ! oggdemux name=audio" 77 | ``` 78 | 79 | Stream a FLAC audio file to the conference, transcoding it to Opus: 80 | 81 | ``` 82 | gst-meet --web-socket-url=wss://your.jitsi.domain/xmpp-websocket \ 83 | --room-name=roomname \ 84 | --send-pipeline="filesrc location=shake-it-off.flac ! queue ! flacdec ! audioconvert ! audioresample ! opusenc name=audio" 85 | ``` 86 | 87 | Stream a .webm file containing VP9 video and Vorbis audio to the conference. This pipeline passes the VP9 stream through efficiently without transcoding, and transcodes the audio from Vorbis to Opus: 88 | 89 | ``` 90 | gst-meet --web-socket-url=wss://your.jitsi.domain/xmpp-websocket \ 91 | --room-name=roomname \ 92 | --send-pipeline="filesrc location=big-buck-bunny_trailer.webm ! queue ! matroskademux name=demuxer 93 | demuxer.video_0 ! queue name=video 94 | demuxer.audio_0 ! queue ! vorbisdec ! audioconvert ! audioresample ! opusenc name=audio" 95 | ``` 96 | 97 | Stream the default video & audio inputs to the conference, encoding as VP9 and Opus, display up to two remote participants' video streams composited side-by-side at 360p each, and play back all incoming audio mixed together (a very basic, but completely native, Jitsi Meet conference!): 98 | 99 | ``` 100 | gst-meet --web-socket-url=wss://your.jitsi.domain/xmpp-websocket \ 101 | --room-name=roomname \ 102 | --recv-video-scale-width=640 \ 103 | --recv-video-scale-height=360 \ 104 | --send-pipeline="autovideosrc ! queue ! videoscale ! video/x-raw,width=640,height=360 ! videoconvert ! vp9enc buffer-size=1000 deadline=1 name=video 105 | autoaudiosrc ! queue ! audioconvert ! audioresample ! opusenc name=audio" \ 106 | --recv-pipeline="audiomixer name=audio ! autoaudiosink 107 | compositor name=video sink_1::xpos=640 ! autovideosink" 108 | ``` 109 | 110 | Record a .webm file for each other participant, containing VP9 video and Opus audio: 111 | 112 | ``` 113 | gst-meet --web-socket-url=wss://your.jitsi.domain/xmpp-websocket \ 114 | --room-name=roomname \ 115 | --video-codec=vp9 \ 116 | --recv-pipeline-participant-template="webmmux name=muxer ! queue ! filesink location={participant_id}.webm 117 | opusenc name=audio ! muxer.audio_0 118 | vp9enc name=video ! muxer.video_0" 119 | ``` 120 | 121 | ## Feature flags 122 | 123 | By default, the `rustls` TLS library is used with the system's native root certificates. This can be turned off by passing `--no-default-features` to Cargo, and one of the following features can be enabled: 124 | 125 | ``` 126 | tls-rustls-native-roots use rustls for TLS with the system's native root certificates (the default) 127 | tls-rustls-webpki-roots use rustls for TLS and bundle webpki's root certificates 128 | tls-native link to the system native TLS library 129 | tls-native-vendored automatically build a copy of OpenSSL and statically link to it 130 | ``` 131 | 132 | Building with the `tls-insecure` feature adds a `--tls-insecure` command line flag which disables certificate verification. Use this with extreme caution. 133 | 134 | The `tls-*` flags only affect the TLS library used for the WebSocket connections (to the XMPP server and to the JVB). Gstreamer uses its own choice of TLS library for its elements. DTLS-SRTP (the media streams) is handled via GStreamer and uses automatically-generated ephemeral certificates which are authenticated over the XMPP signalling channel. 135 | 136 | Building with the `log-rtp` feture adds a `--log-rtp` command line flag which logs information about every RTP and RTCP packet at the `DEBUG` level. 137 | 138 | ## Debugging 139 | 140 | It can sometimes be tricky to get GStreamer pipeline syntax and structure correct. To help with this, you can try setting the `GST_DEBUG` environment variable (for example, `3` is modestly verbose, while `6` produces copious per-packet output). You can also set `GST_DEBUG_DUMP_DOT_DIR` to the relative path to a directory (which must already exist). `.dot` files containing the pipeline graph will be saved to this directory, and can be converted to `.png` with the `dot` tool from GraphViz; for example `dot filename.dot -Tpng > filename.png`. 141 | 142 | ## License 143 | 144 | `gst-meet`, `lib-gst-meet`, `nice` and `nice-sys` are licensed under either of 145 | 146 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 147 | * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 148 | 149 | at your option. 150 | 151 | The dependency `xmpp-parsers` is licensed under the Mozilla Public License, Version 2.0, https://www.mozilla.org/en-US/MPL/2.0/ 152 | 153 | The dependency `gstreamer` is licensed under the GNU Lesser General Public License, Version 2.1, https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html. 154 | 155 | ## Contribution 156 | 157 | Any kinds of contributions are welcome as a pull request. 158 | 159 | Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. 160 | 161 | ## Acknowledgements 162 | 163 | `gst-meet` development is sponsored by [AVStack](https://www.avstack.io/). We provide globally-distributed, scalable, managed Jitsi Meet backends. 164 | -------------------------------------------------------------------------------- /nice-gst-meet/src/enums.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | use std::fmt; 6 | 7 | use glib::translate::*; 8 | use nice_sys as ffi; 9 | 10 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 11 | #[non_exhaustive] 12 | #[doc(alias = "NiceCandidateTransport")] 13 | pub enum CandidateTransport { 14 | #[doc(alias = "NICE_CANDIDATE_TRANSPORT_UDP")] 15 | Udp, 16 | #[doc(alias = "NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE")] 17 | TcpActive, 18 | #[doc(alias = "NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE")] 19 | TcpPassive, 20 | #[doc(alias = "NICE_CANDIDATE_TRANSPORT_TCP_SO")] 21 | TcpSo, 22 | #[doc(hidden)] 23 | __Unknown(i32), 24 | } 25 | 26 | impl fmt::Display for CandidateTransport { 27 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 28 | write!( 29 | f, 30 | "CandidateTransport::{}", 31 | match *self { 32 | Self::Udp => "Udp", 33 | Self::TcpActive => "TcpActive", 34 | Self::TcpPassive => "TcpPassive", 35 | Self::TcpSo => "TcpSo", 36 | _ => "Unknown", 37 | } 38 | ) 39 | } 40 | } 41 | 42 | #[doc(hidden)] 43 | impl IntoGlib for CandidateTransport { 44 | type GlibType = ffi::NiceCandidateTransport; 45 | 46 | fn into_glib(self) -> ffi::NiceCandidateTransport { 47 | match self { 48 | Self::Udp => ffi::NICE_CANDIDATE_TRANSPORT_UDP, 49 | Self::TcpActive => ffi::NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE, 50 | Self::TcpPassive => ffi::NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE, 51 | Self::TcpSo => ffi::NICE_CANDIDATE_TRANSPORT_TCP_SO, 52 | Self::__Unknown(value) => value, 53 | } 54 | } 55 | } 56 | 57 | #[doc(hidden)] 58 | impl FromGlib for CandidateTransport { 59 | unsafe fn from_glib(value: ffi::NiceCandidateTransport) -> Self { 60 | match value { 61 | ffi::NICE_CANDIDATE_TRANSPORT_UDP => Self::Udp, 62 | ffi::NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE => Self::TcpActive, 63 | ffi::NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE => Self::TcpPassive, 64 | ffi::NICE_CANDIDATE_TRANSPORT_TCP_SO => Self::TcpSo, 65 | value => Self::__Unknown(value), 66 | } 67 | } 68 | } 69 | 70 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 71 | #[non_exhaustive] 72 | #[doc(alias = "NiceCandidateType")] 73 | pub enum CandidateType { 74 | #[doc(alias = "NICE_CANDIDATE_TYPE_HOST")] 75 | Host, 76 | #[doc(alias = "NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE")] 77 | ServerReflexive, 78 | #[doc(alias = "NICE_CANDIDATE_TYPE_PEER_REFLEXIVE")] 79 | PeerReflexive, 80 | #[doc(alias = "NICE_CANDIDATE_TYPE_RELAYED")] 81 | Relayed, 82 | #[doc(hidden)] 83 | __Unknown(i32), 84 | } 85 | 86 | impl fmt::Display for CandidateType { 87 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 88 | write!( 89 | f, 90 | "CandidateType::{}", 91 | match *self { 92 | Self::Host => "Host", 93 | Self::ServerReflexive => "ServerReflexive", 94 | Self::PeerReflexive => "PeerReflexive", 95 | Self::Relayed => "Relayed", 96 | _ => "Unknown", 97 | } 98 | ) 99 | } 100 | } 101 | 102 | #[doc(hidden)] 103 | impl IntoGlib for CandidateType { 104 | type GlibType = ffi::NiceCandidateType; 105 | 106 | fn into_glib(self) -> ffi::NiceCandidateType { 107 | match self { 108 | Self::Host => ffi::NICE_CANDIDATE_TYPE_HOST, 109 | Self::ServerReflexive => ffi::NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE, 110 | Self::PeerReflexive => ffi::NICE_CANDIDATE_TYPE_PEER_REFLEXIVE, 111 | Self::Relayed => ffi::NICE_CANDIDATE_TYPE_RELAYED, 112 | Self::__Unknown(value) => value, 113 | } 114 | } 115 | } 116 | 117 | #[doc(hidden)] 118 | impl FromGlib for CandidateType { 119 | unsafe fn from_glib(value: ffi::NiceCandidateType) -> Self { 120 | match value { 121 | ffi::NICE_CANDIDATE_TYPE_HOST => Self::Host, 122 | ffi::NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE => Self::ServerReflexive, 123 | ffi::NICE_CANDIDATE_TYPE_PEER_REFLEXIVE => Self::PeerReflexive, 124 | ffi::NICE_CANDIDATE_TYPE_RELAYED => Self::Relayed, 125 | value => Self::__Unknown(value), 126 | } 127 | } 128 | } 129 | 130 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 131 | #[non_exhaustive] 132 | #[doc(alias = "NiceCompatibility")] 133 | pub enum Compatibility { 134 | #[doc(alias = "NICE_COMPATIBILITY_RFC5245")] 135 | Rfc5245, 136 | #[doc(alias = "NICE_COMPATIBILITY_GOOGLE")] 137 | Google, 138 | #[doc(alias = "NICE_COMPATIBILITY_MSN")] 139 | Msn, 140 | #[doc(alias = "NICE_COMPATIBILITY_WLM2009")] 141 | Wlm2009, 142 | #[doc(alias = "NICE_COMPATIBILITY_OC2007")] 143 | Oc2007, 144 | #[doc(alias = "NICE_COMPATIBILITY_OC2007R2")] 145 | Oc2007r2, 146 | #[doc(hidden)] 147 | __Unknown(i32), 148 | } 149 | 150 | impl fmt::Display for Compatibility { 151 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 152 | write!( 153 | f, 154 | "Compatibility::{}", 155 | match *self { 156 | Self::Rfc5245 => "Rfc5245", 157 | Self::Google => "Google", 158 | Self::Msn => "Msn", 159 | Self::Wlm2009 => "Wlm2009", 160 | Self::Oc2007 => "Oc2007", 161 | Self::Oc2007r2 => "Oc2007r2", 162 | _ => "Unknown", 163 | } 164 | ) 165 | } 166 | } 167 | 168 | #[doc(hidden)] 169 | impl IntoGlib for Compatibility { 170 | type GlibType = ffi::NiceCompatibility; 171 | 172 | fn into_glib(self) -> ffi::NiceCompatibility { 173 | match self { 174 | Self::Rfc5245 => ffi::NICE_COMPATIBILITY_RFC5245, 175 | Self::Google => ffi::NICE_COMPATIBILITY_GOOGLE, 176 | Self::Msn => ffi::NICE_COMPATIBILITY_MSN, 177 | Self::Wlm2009 => ffi::NICE_COMPATIBILITY_WLM2009, 178 | Self::Oc2007 => ffi::NICE_COMPATIBILITY_OC2007, 179 | Self::Oc2007r2 => ffi::NICE_COMPATIBILITY_OC2007R2, 180 | Self::__Unknown(value) => value, 181 | } 182 | } 183 | } 184 | 185 | #[doc(hidden)] 186 | impl FromGlib for Compatibility { 187 | unsafe fn from_glib(value: ffi::NiceCompatibility) -> Self { 188 | match value { 189 | ffi::NICE_COMPATIBILITY_RFC5245 => Self::Rfc5245, 190 | ffi::NICE_COMPATIBILITY_GOOGLE => Self::Google, 191 | ffi::NICE_COMPATIBILITY_MSN => Self::Msn, 192 | ffi::NICE_COMPATIBILITY_WLM2009 => Self::Wlm2009, 193 | ffi::NICE_COMPATIBILITY_OC2007 => Self::Oc2007, 194 | ffi::NICE_COMPATIBILITY_OC2007R2 => Self::Oc2007r2, 195 | value => Self::__Unknown(value), 196 | } 197 | } 198 | } 199 | 200 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 201 | #[non_exhaustive] 202 | #[doc(alias = "NiceComponentState")] 203 | pub enum ComponentState { 204 | #[doc(alias = "NICE_COMPONENT_STATE_DISCONNECTED")] 205 | Disconnected, 206 | #[doc(alias = "NICE_COMPONENT_STATE_GATHERING")] 207 | Gathering, 208 | #[doc(alias = "NICE_COMPONENT_STATE_CONNECTING")] 209 | Connecting, 210 | #[doc(alias = "NICE_COMPONENT_STATE_CONNECTED")] 211 | Connected, 212 | #[doc(alias = "NICE_COMPONENT_STATE_READY")] 213 | Ready, 214 | #[doc(alias = "NICE_COMPONENT_STATE_FAILED")] 215 | Failed, 216 | #[doc(alias = "NICE_COMPONENT_STATE_LAST")] 217 | Last, 218 | #[doc(hidden)] 219 | __Unknown(i32), 220 | } 221 | 222 | impl fmt::Display for ComponentState { 223 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 224 | write!( 225 | f, 226 | "ComponentState::{}", 227 | match *self { 228 | Self::Disconnected => "Disconnected", 229 | Self::Gathering => "Gathering", 230 | Self::Connecting => "Connecting", 231 | Self::Connected => "Connected", 232 | Self::Ready => "Ready", 233 | Self::Failed => "Failed", 234 | Self::Last => "Last", 235 | _ => "Unknown", 236 | } 237 | ) 238 | } 239 | } 240 | 241 | #[doc(hidden)] 242 | impl IntoGlib for ComponentState { 243 | type GlibType = ffi::NiceComponentState; 244 | 245 | fn into_glib(self) -> ffi::NiceComponentState { 246 | match self { 247 | Self::Disconnected => ffi::NICE_COMPONENT_STATE_DISCONNECTED, 248 | Self::Gathering => ffi::NICE_COMPONENT_STATE_GATHERING, 249 | Self::Connecting => ffi::NICE_COMPONENT_STATE_CONNECTING, 250 | Self::Connected => ffi::NICE_COMPONENT_STATE_CONNECTED, 251 | Self::Ready => ffi::NICE_COMPONENT_STATE_READY, 252 | Self::Failed => ffi::NICE_COMPONENT_STATE_FAILED, 253 | Self::Last => ffi::NICE_COMPONENT_STATE_LAST, 254 | Self::__Unknown(value) => value, 255 | } 256 | } 257 | } 258 | 259 | #[doc(hidden)] 260 | impl FromGlib for ComponentState { 261 | unsafe fn from_glib(value: ffi::NiceComponentState) -> Self { 262 | match value { 263 | ffi::NICE_COMPONENT_STATE_DISCONNECTED => Self::Disconnected, 264 | ffi::NICE_COMPONENT_STATE_GATHERING => Self::Gathering, 265 | ffi::NICE_COMPONENT_STATE_CONNECTING => Self::Connecting, 266 | ffi::NICE_COMPONENT_STATE_CONNECTED => Self::Connected, 267 | ffi::NICE_COMPONENT_STATE_READY => Self::Ready, 268 | ffi::NICE_COMPONENT_STATE_FAILED => Self::Failed, 269 | ffi::NICE_COMPONENT_STATE_LAST => Self::Last, 270 | value => Self::__Unknown(value), 271 | } 272 | } 273 | } 274 | 275 | #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] 276 | #[non_exhaustive] 277 | #[doc(alias = "NiceRelayType")] 278 | pub enum RelayType { 279 | #[doc(alias = "NICE_RELAY_TYPE_TURN_UDP")] 280 | Udp, 281 | #[doc(alias = "NICE_RELAY_TYPE_TURN_TCP")] 282 | Tcp, 283 | #[doc(alias = "NICE_RELAY_TYPE_TURN_TLS")] 284 | Tls, 285 | #[doc(hidden)] 286 | __Unknown(i32), 287 | } 288 | 289 | impl fmt::Display for RelayType { 290 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 291 | write!( 292 | f, 293 | "RelayType::{}", 294 | match *self { 295 | Self::Udp => "Udp", 296 | Self::Tcp => "Tcp", 297 | Self::Tls => "Tls", 298 | _ => "Unknown", 299 | } 300 | ) 301 | } 302 | } 303 | 304 | #[doc(hidden)] 305 | impl IntoGlib for RelayType { 306 | type GlibType = ffi::NiceRelayType; 307 | 308 | fn into_glib(self) -> ffi::NiceRelayType { 309 | match self { 310 | Self::Udp => ffi::NICE_RELAY_TYPE_TURN_UDP, 311 | Self::Tcp => ffi::NICE_RELAY_TYPE_TURN_TCP, 312 | Self::Tls => ffi::NICE_RELAY_TYPE_TURN_TLS, 313 | Self::__Unknown(value) => value, 314 | } 315 | } 316 | } 317 | 318 | #[doc(hidden)] 319 | impl FromGlib for RelayType { 320 | unsafe fn from_glib(value: ffi::NiceRelayType) -> Self { 321 | match value { 322 | ffi::NICE_RELAY_TYPE_TURN_UDP => Self::Udp, 323 | ffi::NICE_RELAY_TYPE_TURN_TCP => Self::Tcp, 324 | ffi::NICE_RELAY_TYPE_TURN_TLS => Self::Tls, 325 | value => Self::__Unknown(value), 326 | } 327 | } 328 | } 329 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /gst-meet/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /lib-gst-meet/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /nice-gst-meet/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /nice-gst-meet-sys/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /jitsi-xmpp-parsers/src/jingle.rs: -------------------------------------------------------------------------------- 1 | use std::convert::TryFrom; 2 | 3 | use jid::Jid; 4 | use xmpp_parsers::{ 5 | iq::IqSetPayload, 6 | jingle::{ContentId, Creator, Disposition, ReasonElement, Senders, SessionId}, 7 | jingle_grouping::Group, 8 | jingle_ibb::Transport as IbbTransport, 9 | jingle_s5b::Transport as Socks5Transport, 10 | ns::{JINGLE, JINGLE_GROUPING, JINGLE_IBB, JINGLE_ICE_UDP, JINGLE_RTP, JINGLE_S5B}, 11 | Element, Error, 12 | }; 13 | 14 | use crate::{ 15 | jingle_ice_udp::Transport as IceUdpTransport, jingle_rtp::Description as RtpDescription, 16 | }; 17 | 18 | generate_attribute!( 19 | /// The action attribute. 20 | Action, "action", { 21 | /// Accept a content-add action received from another party. 22 | ContentAccept => "content-accept", 23 | 24 | /// Add one or more new content definitions to the session. 25 | ContentAdd => "content-add", 26 | 27 | /// Change the directionality of media sending. 28 | ContentModify => "content-modify", 29 | 30 | /// Reject a content-add action received from another party. 31 | ContentReject => "content-reject", 32 | 33 | /// Remove one or more content definitions from the session. 34 | ContentRemove => "content-remove", 35 | 36 | /// Exchange information about parameters for an application type. 37 | DescriptionInfo => "description-info", 38 | 39 | /// Exchange information about security preconditions. 40 | SecurityInfo => "security-info", 41 | 42 | /// Definitively accept a session negotiation. 43 | SessionAccept => "session-accept", 44 | 45 | /// Send session-level information, such as a ping or a ringing message. 46 | SessionInfo => "session-info", 47 | 48 | /// Request negotiation of a new Jingle session. 49 | SessionInitiate => "session-initiate", 50 | 51 | /// End an existing session. 52 | SessionTerminate => "session-terminate", 53 | 54 | /// Accept a transport-replace action received from another party. 55 | TransportAccept => "transport-accept", 56 | 57 | /// Exchange transport candidates. 58 | TransportInfo => "transport-info", 59 | 60 | /// Reject a transport-replace action received from another party. 61 | TransportReject => "transport-reject", 62 | 63 | /// Redefine a transport method or replace it with a different method. 64 | TransportReplace => "transport-replace", 65 | 66 | /// --- Non-standard values used by Jitsi Meet: --- 67 | 68 | /// Add a source to existing content. 69 | SourceAdd => "source-add", 70 | 71 | /// Remove a source from existing content. 72 | SourceRemove => "source-remove", 73 | } 74 | ); 75 | 76 | /// The main Jingle container, to be included in an iq stanza. 77 | #[derive(Debug, Clone, PartialEq)] 78 | pub struct Jingle { 79 | /// The action to execute on both ends. 80 | pub action: Action, 81 | 82 | /// Who the initiator is. 83 | pub initiator: Option, 84 | 85 | /// Who the responder is. 86 | pub responder: Option, 87 | 88 | /// Unique session identifier between two entities. 89 | pub sid: SessionId, 90 | 91 | /// A list of contents to be negotiated in this session. 92 | pub contents: Vec, 93 | 94 | /// An optional reason. 95 | pub reason: Option, 96 | 97 | /// An optional grouping. 98 | pub group: Option, 99 | 100 | /// Payloads to be included. 101 | pub other: Vec, 102 | } 103 | 104 | impl IqSetPayload for Jingle {} 105 | 106 | impl Jingle { 107 | /// Create a new Jingle element. 108 | pub fn new(action: Action, sid: SessionId) -> Jingle { 109 | Jingle { 110 | action, 111 | sid, 112 | initiator: None, 113 | responder: None, 114 | contents: Vec::new(), 115 | reason: None, 116 | group: None, 117 | other: Vec::new(), 118 | } 119 | } 120 | 121 | /// Set the initiator’s JID. 122 | pub fn with_initiator(mut self, initiator: Jid) -> Jingle { 123 | self.initiator = Some(initiator); 124 | self 125 | } 126 | 127 | /// Set the responder’s JID. 128 | pub fn with_responder(mut self, responder: Jid) -> Jingle { 129 | self.responder = Some(responder); 130 | self 131 | } 132 | 133 | /// Add a content to this Jingle container. 134 | pub fn add_content(mut self, content: Content) -> Jingle { 135 | self.contents.push(content); 136 | self 137 | } 138 | 139 | /// Set the reason in this Jingle container. 140 | pub fn set_reason(mut self, reason: ReasonElement) -> Jingle { 141 | self.reason = Some(reason); 142 | self 143 | } 144 | 145 | /// Set the grouping in this Jingle container. 146 | pub fn set_group(mut self, group: Group) -> Jingle { 147 | self.group = Some(group); 148 | self 149 | } 150 | } 151 | 152 | impl TryFrom for Jingle { 153 | type Error = Error; 154 | 155 | fn try_from(root: Element) -> Result { 156 | check_self!(root, "jingle", JINGLE, "Jingle"); 157 | 158 | let mut jingle = Jingle { 159 | action: get_attr!(root, "action", Required), 160 | initiator: get_attr!(root, "initiator", Option), 161 | responder: get_attr!(root, "responder", Option), 162 | sid: get_attr!(root, "sid", Required), 163 | contents: vec![], 164 | reason: None, 165 | group: None, 166 | other: vec![], 167 | }; 168 | 169 | for child in root.children().cloned() { 170 | if child.is("content", JINGLE) { 171 | let content = Content::try_from(child)?; 172 | jingle.contents.push(content); 173 | } 174 | else if child.is("reason", JINGLE) { 175 | if jingle.reason.is_some() { 176 | return Err(Error::ParseError( 177 | "Jingle must not have more than one reason.", 178 | )); 179 | } 180 | let reason = ReasonElement::try_from(child)?; 181 | jingle.reason = Some(reason); 182 | } 183 | else if child.is("group", JINGLE_GROUPING) { 184 | if jingle.group.is_some() { 185 | return Err(Error::ParseError( 186 | "Jingle must not have more than one grouping.", 187 | )); 188 | } 189 | let group = Group::try_from(child)?; 190 | jingle.group = Some(group); 191 | } 192 | else { 193 | jingle.other.push(child); 194 | } 195 | } 196 | 197 | Ok(jingle) 198 | } 199 | } 200 | 201 | impl From for Element { 202 | fn from(jingle: Jingle) -> Element { 203 | Element::builder("jingle", JINGLE) 204 | .attr("action", jingle.action) 205 | .attr("initiator", jingle.initiator) 206 | .attr("responder", jingle.responder) 207 | .attr("sid", jingle.sid) 208 | .append_all(jingle.contents) 209 | .append_all(jingle.reason.map(Element::from)) 210 | .append_all(jingle.group.map(Element::from)) 211 | .build() 212 | } 213 | } 214 | 215 | /// Enum wrapping all of the various supported descriptions of a Content. 216 | #[derive(Debug, Clone, PartialEq)] 217 | pub enum Description { 218 | /// Jingle RTP Sessions (XEP-0167) description. 219 | Rtp(RtpDescription), 220 | 221 | /// To be used for any description that isn’t known at compile-time. 222 | Unknown(Element), 223 | } 224 | 225 | impl TryFrom for Description { 226 | type Error = Error; 227 | 228 | fn try_from(elem: Element) -> Result { 229 | Ok(if elem.is("description", JINGLE_RTP) { 230 | Description::Rtp(RtpDescription::try_from(elem)?) 231 | } 232 | else { 233 | Description::Unknown(elem) 234 | }) 235 | } 236 | } 237 | 238 | impl From for Description { 239 | fn from(desc: RtpDescription) -> Description { 240 | Description::Rtp(desc) 241 | } 242 | } 243 | 244 | impl From for Element { 245 | fn from(desc: Description) -> Element { 246 | match desc { 247 | Description::Rtp(desc) => desc.into(), 248 | Description::Unknown(elem) => elem, 249 | } 250 | } 251 | } 252 | 253 | /// Enum wrapping all of the various supported transports of a Content. 254 | #[derive(Debug, Clone, PartialEq)] 255 | pub enum Transport { 256 | /// Jingle ICE-UDP Bytestreams (XEP-0176) transport. 257 | IceUdp(IceUdpTransport), 258 | 259 | /// Jingle In-Band Bytestreams (XEP-0261) transport. 260 | Ibb(IbbTransport), 261 | 262 | /// Jingle SOCKS5 Bytestreams (XEP-0260) transport. 263 | Socks5(Socks5Transport), 264 | 265 | /// To be used for any transport that isn’t known at compile-time. 266 | Unknown(Element), 267 | } 268 | 269 | impl TryFrom for Transport { 270 | type Error = Error; 271 | 272 | fn try_from(elem: Element) -> Result { 273 | Ok(if elem.is("transport", JINGLE_ICE_UDP) { 274 | Transport::IceUdp(IceUdpTransport::try_from(elem)?) 275 | } 276 | else if elem.is("transport", JINGLE_IBB) { 277 | Transport::Ibb(IbbTransport::try_from(elem)?) 278 | } 279 | else if elem.is("transport", JINGLE_S5B) { 280 | Transport::Socks5(Socks5Transport::try_from(elem)?) 281 | } 282 | else { 283 | Transport::Unknown(elem) 284 | }) 285 | } 286 | } 287 | 288 | impl From for Transport { 289 | fn from(transport: IceUdpTransport) -> Transport { 290 | Transport::IceUdp(transport) 291 | } 292 | } 293 | 294 | impl From for Transport { 295 | fn from(transport: IbbTransport) -> Transport { 296 | Transport::Ibb(transport) 297 | } 298 | } 299 | 300 | impl From for Transport { 301 | fn from(transport: Socks5Transport) -> Transport { 302 | Transport::Socks5(transport) 303 | } 304 | } 305 | 306 | impl From for Element { 307 | fn from(transport: Transport) -> Element { 308 | match transport { 309 | Transport::IceUdp(transport) => transport.into(), 310 | Transport::Ibb(transport) => transport.into(), 311 | Transport::Socks5(transport) => transport.into(), 312 | Transport::Unknown(elem) => elem, 313 | } 314 | } 315 | } 316 | 317 | generate_element!( 318 | /// Describes a session’s content, there can be multiple content in one 319 | /// session. 320 | Content, "content", JINGLE, 321 | attributes: [ 322 | /// Who created this content. 323 | creator: Option = "creator", 324 | 325 | /// How the content definition is to be interpreted by the recipient. 326 | disposition: Default = "disposition", 327 | 328 | /// A per-session unique identifier for this content. 329 | name: Required = "name", 330 | 331 | /// Who can send data for this content. 332 | senders: Default = "senders", 333 | ], 334 | children: [ 335 | /// What to send. 336 | description: Option = ("description", *) => Description, 337 | 338 | /// How to send it. 339 | transport: Option = ("transport", *) => Transport, 340 | 341 | /// With which security. 342 | security: Option = ("security", JINGLE) => Element 343 | ] 344 | ); 345 | 346 | impl Content { 347 | /// Create a new content. 348 | pub fn new(creator: Creator, name: ContentId) -> Content { 349 | Content { 350 | creator: Some(creator), 351 | name, 352 | disposition: Disposition::Session, 353 | senders: Senders::Both, 354 | description: None, 355 | transport: None, 356 | security: None, 357 | } 358 | } 359 | 360 | /// Set how the content is to be interpreted by the recipient. 361 | pub fn with_disposition(mut self, disposition: Disposition) -> Content { 362 | self.disposition = disposition; 363 | self 364 | } 365 | 366 | /// Specify who can send data for this content. 367 | pub fn with_senders(mut self, senders: Senders) -> Content { 368 | self.senders = senders; 369 | self 370 | } 371 | 372 | /// Set the description of this content. 373 | pub fn with_description>(mut self, description: D) -> Content { 374 | self.description = Some(description.into()); 375 | self 376 | } 377 | 378 | /// Set the transport of this content. 379 | pub fn with_transport>(mut self, transport: T) -> Content { 380 | self.transport = Some(transport.into()); 381 | self 382 | } 383 | 384 | /// Set the security of this content. 385 | pub fn with_security(mut self, security: Element) -> Content { 386 | self.security = Some(security); 387 | self 388 | } 389 | } 390 | -------------------------------------------------------------------------------- /nice-gst-meet-sys/tests/abi.rs: -------------------------------------------------------------------------------- 1 | // Generated by gir (https://github.com/gtk-rs/gir @ 5bbf6cb) 2 | // from ../../gir-files (@ 8e47c67) 3 | // DO NOT EDIT 4 | 5 | use std::{ 6 | env, 7 | error::Error, 8 | ffi::OsString, 9 | mem::{align_of, size_of}, 10 | path::Path, 11 | process::Command, 12 | str, 13 | }; 14 | 15 | use nice_sys::*; 16 | use tempfile::Builder; 17 | 18 | static PACKAGES: &[&str] = &["nice"]; 19 | 20 | #[derive(Clone, Debug)] 21 | struct Compiler { 22 | pub args: Vec, 23 | } 24 | 25 | impl Compiler { 26 | pub fn new() -> Result> { 27 | let mut args = get_var("CC", "cc")?; 28 | args.push("-Wno-deprecated-declarations".to_owned()); 29 | // For _Generic 30 | args.push("-std=c11".to_owned()); 31 | // For %z support in printf when using MinGW. 32 | args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); 33 | args.extend(get_var("CFLAGS", "")?); 34 | args.extend(get_var("CPPFLAGS", "")?); 35 | args.extend(pkg_config_cflags(PACKAGES)?); 36 | Ok(Self { args }) 37 | } 38 | 39 | pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { 40 | let mut cmd = self.to_command(); 41 | cmd.arg(src); 42 | cmd.arg("-o"); 43 | cmd.arg(out); 44 | let status = cmd.spawn()?.wait()?; 45 | if !status.success() { 46 | return Err(format!("compilation command {:?} failed, {}", &cmd, status).into()); 47 | } 48 | Ok(()) 49 | } 50 | 51 | fn to_command(&self) -> Command { 52 | let mut cmd = Command::new(&self.args[0]); 53 | cmd.args(&self.args[1..]); 54 | cmd 55 | } 56 | } 57 | 58 | fn get_var(name: &str, default: &str) -> Result, Box> { 59 | match env::var(name) { 60 | Ok(value) => Ok(shell_words::split(&value)?), 61 | Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), 62 | Err(err) => Err(format!("{} {}", name, err).into()), 63 | } 64 | } 65 | 66 | fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { 67 | if packages.is_empty() { 68 | return Ok(Vec::new()); 69 | } 70 | let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); 71 | let mut cmd = Command::new(pkg_config); 72 | cmd.arg("--cflags"); 73 | cmd.args(packages); 74 | let out = cmd.output()?; 75 | if !out.status.success() { 76 | return Err(format!("command {:?} returned {}", &cmd, out.status).into()); 77 | } 78 | let stdout = str::from_utf8(&out.stdout)?; 79 | Ok(shell_words::split(stdout.trim())?) 80 | } 81 | 82 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] 83 | struct Layout { 84 | size: usize, 85 | alignment: usize, 86 | } 87 | 88 | #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] 89 | struct Results { 90 | /// Number of successfully completed tests. 91 | passed: usize, 92 | /// Total number of failed tests (including those that failed to compile). 93 | failed: usize, 94 | } 95 | 96 | impl Results { 97 | fn record_passed(&mut self) { 98 | self.passed += 1; 99 | } 100 | 101 | fn record_failed(&mut self) { 102 | self.failed += 1; 103 | } 104 | 105 | fn summary(&self) -> String { 106 | format!("{} passed; {} failed", self.passed, self.failed) 107 | } 108 | 109 | fn expect_total_success(&self) { 110 | if self.failed == 0 { 111 | println!("OK: {}", self.summary()); 112 | } 113 | else { 114 | panic!("FAILED: {}", self.summary()); 115 | }; 116 | } 117 | } 118 | 119 | #[test] 120 | fn cross_validate_constants_with_c() { 121 | let mut c_constants: Vec<(String, String)> = Vec::new(); 122 | 123 | for l in get_c_output("constant").unwrap().lines() { 124 | let mut words = l.trim().split(';'); 125 | let name = words.next().expect("Failed to parse name").to_owned(); 126 | let value = words 127 | .next() 128 | .and_then(|s| s.parse().ok()) 129 | .expect("Failed to parse value"); 130 | c_constants.push((name, value)); 131 | } 132 | 133 | let mut results = Results::default(); 134 | 135 | for ((rust_name, rust_value), (c_name, c_value)) in RUST_CONSTANTS.iter().zip(c_constants.iter()) 136 | { 137 | if rust_name != c_name { 138 | results.record_failed(); 139 | eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,); 140 | continue; 141 | } 142 | 143 | if rust_value != c_value { 144 | results.record_failed(); 145 | eprintln!( 146 | "Constant value mismatch for {}\nRust: {:?}\nC: {:?}", 147 | rust_name, rust_value, &c_value 148 | ); 149 | continue; 150 | } 151 | 152 | results.record_passed(); 153 | } 154 | 155 | results.expect_total_success(); 156 | } 157 | 158 | #[test] 159 | fn cross_validate_layout_with_c() { 160 | let mut c_layouts = Vec::new(); 161 | 162 | for l in get_c_output("layout").unwrap().lines() { 163 | let mut words = l.trim().split(';'); 164 | let name = words.next().expect("Failed to parse name").to_owned(); 165 | let size = words 166 | .next() 167 | .and_then(|s| s.parse().ok()) 168 | .expect("Failed to parse size"); 169 | let alignment = words 170 | .next() 171 | .and_then(|s| s.parse().ok()) 172 | .expect("Failed to parse alignment"); 173 | c_layouts.push((name, Layout { size, alignment })); 174 | } 175 | 176 | let mut results = Results::default(); 177 | 178 | for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) { 179 | if rust_name != c_name { 180 | results.record_failed(); 181 | eprintln!("Name mismatch:\nRust: {:?}\nC: {:?}", rust_name, c_name,); 182 | continue; 183 | } 184 | 185 | if rust_layout != c_layout { 186 | results.record_failed(); 187 | eprintln!( 188 | "Layout mismatch for {}\nRust: {:?}\nC: {:?}", 189 | rust_name, rust_layout, &c_layout 190 | ); 191 | continue; 192 | } 193 | 194 | results.record_passed(); 195 | } 196 | 197 | results.expect_total_success(); 198 | } 199 | 200 | fn get_c_output(name: &str) -> Result> { 201 | let tmpdir = Builder::new().prefix("abi").tempdir()?; 202 | let exe = tmpdir.path().join(name); 203 | let c_file = Path::new("tests").join(name).with_extension("c"); 204 | 205 | let cc = Compiler::new().expect("configured compiler"); 206 | cc.compile(&c_file, &exe)?; 207 | 208 | let mut abi_cmd = Command::new(exe); 209 | let output = abi_cmd.output()?; 210 | if !output.status.success() { 211 | return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into()); 212 | } 213 | 214 | Ok(String::from_utf8(output.stdout)?) 215 | } 216 | 217 | const RUST_LAYOUTS: &[(&str, Layout)] = &[ 218 | ( 219 | "NiceAddress", 220 | Layout { 221 | size: size_of::(), 222 | alignment: align_of::(), 223 | }, 224 | ), 225 | ( 226 | "NiceAgentClass", 227 | Layout { 228 | size: size_of::(), 229 | alignment: align_of::(), 230 | }, 231 | ), 232 | ( 233 | "NiceAgentOption", 234 | Layout { 235 | size: size_of::(), 236 | alignment: align_of::(), 237 | }, 238 | ), 239 | ( 240 | "NiceCandidate", 241 | Layout { 242 | size: size_of::(), 243 | alignment: align_of::(), 244 | }, 245 | ), 246 | ( 247 | "NiceCandidateTransport", 248 | Layout { 249 | size: size_of::(), 250 | alignment: align_of::(), 251 | }, 252 | ), 253 | ( 254 | "NiceCandidateType", 255 | Layout { 256 | size: size_of::(), 257 | alignment: align_of::(), 258 | }, 259 | ), 260 | ( 261 | "NiceCompatibility", 262 | Layout { 263 | size: size_of::(), 264 | alignment: align_of::(), 265 | }, 266 | ), 267 | ( 268 | "NiceComponentState", 269 | Layout { 270 | size: size_of::(), 271 | alignment: align_of::(), 272 | }, 273 | ), 274 | ( 275 | "NiceComponentType", 276 | Layout { 277 | size: size_of::(), 278 | alignment: align_of::(), 279 | }, 280 | ), 281 | ( 282 | "NiceInputMessage", 283 | Layout { 284 | size: size_of::(), 285 | alignment: align_of::(), 286 | }, 287 | ), 288 | ( 289 | "NiceNominationMode", 290 | Layout { 291 | size: size_of::(), 292 | alignment: align_of::(), 293 | }, 294 | ), 295 | ( 296 | "NiceOutputMessage", 297 | Layout { 298 | size: size_of::(), 299 | alignment: align_of::(), 300 | }, 301 | ), 302 | ( 303 | "NiceProxyType", 304 | Layout { 305 | size: size_of::(), 306 | alignment: align_of::(), 307 | }, 308 | ), 309 | ( 310 | "NiceRelayType", 311 | Layout { 312 | size: size_of::(), 313 | alignment: align_of::(), 314 | }, 315 | ), 316 | ( 317 | "PseudoTcpCallbacks", 318 | Layout { 319 | size: size_of::(), 320 | alignment: align_of::(), 321 | }, 322 | ), 323 | ( 324 | "PseudoTcpDebugLevel", 325 | Layout { 326 | size: size_of::(), 327 | alignment: align_of::(), 328 | }, 329 | ), 330 | ( 331 | "PseudoTcpShutdown", 332 | Layout { 333 | size: size_of::(), 334 | alignment: align_of::(), 335 | }, 336 | ), 337 | ( 338 | "PseudoTcpState", 339 | Layout { 340 | size: size_of::(), 341 | alignment: align_of::(), 342 | }, 343 | ), 344 | ( 345 | "PseudoTcpWriteResult", 346 | Layout { 347 | size: size_of::(), 348 | alignment: align_of::(), 349 | }, 350 | ), 351 | ]; 352 | 353 | const RUST_CONSTANTS: &[(&str, &str)] = &[ 354 | ("NICE_AGENT_MAX_REMOTE_CANDIDATES", "25"), 355 | ("(guint) NICE_AGENT_OPTION_CONSENT_FRESHNESS", "32"), 356 | ("(guint) NICE_AGENT_OPTION_ICE_TRICKLE", "8"), 357 | ("(guint) NICE_AGENT_OPTION_LITE_MODE", "4"), 358 | ("(guint) NICE_AGENT_OPTION_REGULAR_NOMINATION", "1"), 359 | ("(guint) NICE_AGENT_OPTION_RELIABLE", "2"), 360 | ("(guint) NICE_AGENT_OPTION_SUPPORT_RENOMINATION", "16"), 361 | ("NICE_CANDIDATE_MAX_FOUNDATION", "33"), 362 | ("NICE_CANDIDATE_MAX_LOCAL_ADDRESSES", "64"), 363 | ("NICE_CANDIDATE_MAX_TURN_SERVERS", "8"), 364 | ("(gint) NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE", "1"), 365 | ("(gint) NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE", "2"), 366 | ("(gint) NICE_CANDIDATE_TRANSPORT_TCP_SO", "3"), 367 | ("(gint) NICE_CANDIDATE_TRANSPORT_UDP", "0"), 368 | ("(gint) NICE_CANDIDATE_TYPE_HOST", "0"), 369 | ("(gint) NICE_CANDIDATE_TYPE_PEER_REFLEXIVE", "2"), 370 | ("(gint) NICE_CANDIDATE_TYPE_RELAYED", "3"), 371 | ("(gint) NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE", "1"), 372 | ("(gint) NICE_COMPATIBILITY_DRAFT19", "0"), 373 | ("(gint) NICE_COMPATIBILITY_GOOGLE", "1"), 374 | ("(gint) NICE_COMPATIBILITY_LAST", "5"), 375 | ("(gint) NICE_COMPATIBILITY_MSN", "2"), 376 | ("(gint) NICE_COMPATIBILITY_OC2007", "4"), 377 | ("(gint) NICE_COMPATIBILITY_OC2007R2", "5"), 378 | ("(gint) NICE_COMPATIBILITY_RFC5245", "0"), 379 | ("(gint) NICE_COMPATIBILITY_WLM2009", "3"), 380 | ("(gint) NICE_COMPONENT_STATE_CONNECTED", "3"), 381 | ("(gint) NICE_COMPONENT_STATE_CONNECTING", "2"), 382 | ("(gint) NICE_COMPONENT_STATE_DISCONNECTED", "0"), 383 | ("(gint) NICE_COMPONENT_STATE_FAILED", "5"), 384 | ("(gint) NICE_COMPONENT_STATE_GATHERING", "1"), 385 | ("(gint) NICE_COMPONENT_STATE_LAST", "6"), 386 | ("(gint) NICE_COMPONENT_STATE_READY", "4"), 387 | ("(gint) NICE_COMPONENT_TYPE_RTCP", "2"), 388 | ("(gint) NICE_COMPONENT_TYPE_RTP", "1"), 389 | ("(gint) NICE_NOMINATION_MODE_AGGRESSIVE", "1"), 390 | ("(gint) NICE_NOMINATION_MODE_REGULAR", "0"), 391 | ("(gint) NICE_PROXY_TYPE_HTTP", "2"), 392 | ("(gint) NICE_PROXY_TYPE_LAST", "2"), 393 | ("(gint) NICE_PROXY_TYPE_NONE", "0"), 394 | ("(gint) NICE_PROXY_TYPE_SOCKS5", "1"), 395 | ("(gint) NICE_RELAY_TYPE_TURN_TCP", "1"), 396 | ("(gint) NICE_RELAY_TYPE_TURN_TLS", "2"), 397 | ("(gint) NICE_RELAY_TYPE_TURN_UDP", "0"), 398 | ("(gint) PSEUDO_TCP_CLOSED", "4"), 399 | ("(gint) PSEUDO_TCP_CLOSE_WAIT", "9"), 400 | ("(gint) PSEUDO_TCP_CLOSING", "7"), 401 | ("(gint) PSEUDO_TCP_DEBUG_NONE", "0"), 402 | ("(gint) PSEUDO_TCP_DEBUG_NORMAL", "1"), 403 | ("(gint) PSEUDO_TCP_DEBUG_VERBOSE", "2"), 404 | ("(gint) PSEUDO_TCP_ESTABLISHED", "3"), 405 | ("(gint) PSEUDO_TCP_FIN_WAIT_1", "5"), 406 | ("(gint) PSEUDO_TCP_FIN_WAIT_2", "6"), 407 | ("(gint) PSEUDO_TCP_LAST_ACK", "10"), 408 | ("(gint) PSEUDO_TCP_LISTEN", "0"), 409 | ("(gint) PSEUDO_TCP_SHUTDOWN_RD", "0"), 410 | ("(gint) PSEUDO_TCP_SHUTDOWN_RDWR", "2"), 411 | ("(gint) PSEUDO_TCP_SHUTDOWN_WR", "1"), 412 | ("(gint) PSEUDO_TCP_SYN_RECEIVED", "2"), 413 | ("(gint) PSEUDO_TCP_SYN_SENT", "1"), 414 | ("(gint) PSEUDO_TCP_TIME_WAIT", "8"), 415 | ("(gint) WR_FAIL", "2"), 416 | ("(gint) WR_SUCCESS", "0"), 417 | ("(gint) WR_TOO_LARGE", "1"), 418 | ]; 419 | -------------------------------------------------------------------------------- /lib-gst-meet/src/xmpp/connection.rs: -------------------------------------------------------------------------------- 1 | use std::{convert::TryFrom, fmt, future::Future, sync::Arc}; 2 | 3 | use anyhow::{anyhow, bail, Context, Result}; 4 | use futures::{ 5 | sink::{Sink, SinkExt}, 6 | stream::{Stream, StreamExt, TryStreamExt}, 7 | }; 8 | use rand::{thread_rng, RngCore}; 9 | use tokio::sync::{mpsc, oneshot, Mutex}; 10 | use tokio_stream::wrappers::ReceiverStream; 11 | use tokio_tungstenite::tungstenite::{ 12 | http::{Request, Uri}, 13 | Message, 14 | }; 15 | use tracing::{debug, error, info, warn}; 16 | use xmpp_parsers::{ 17 | bind::{BindQuery, BindResponse}, 18 | disco::{DiscoInfoQuery, DiscoInfoResult}, 19 | iq::{Iq, IqType}, 20 | sasl::{Auth, Mechanism, Success}, 21 | websocket::Open, 22 | BareJid, Element, FullJid, Jid, 23 | }; 24 | 25 | use crate::{ 26 | pinger::Pinger, stanza_filter::StanzaFilter, tls::wss_connector, util::generate_id, xmpp, 27 | }; 28 | 29 | #[derive(Debug, Clone, Copy)] 30 | enum ConnectionState { 31 | OpeningPreAuthentication, 32 | ReceivingFeaturesPreAuthentication, 33 | Authenticating, 34 | OpeningPostAuthentication, 35 | ReceivingFeaturesPostAuthentication, 36 | Binding, 37 | Discovering, 38 | DiscoveringExternalServices, 39 | Idle, 40 | } 41 | 42 | struct ConnectionInner { 43 | state: ConnectionState, 44 | jid: Option, 45 | xmpp_domain: BareJid, 46 | authentication: Authentication, 47 | external_services: Vec, 48 | connected_tx: Option>>, 49 | stanza_filters: Vec>, 50 | } 51 | 52 | impl fmt::Debug for ConnectionInner { 53 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 54 | f.debug_struct("ConnectionInner") 55 | .field("state", &self.state) 56 | .field("jid", &self.jid) 57 | .finish() 58 | } 59 | } 60 | 61 | #[derive(Debug, Clone)] 62 | pub struct Connection { 63 | pub(crate) tx: mpsc::Sender, 64 | inner: Arc>, 65 | pub(crate) tls_insecure: bool, 66 | } 67 | 68 | #[derive(Debug, Clone)] 69 | pub enum Authentication { 70 | Anonymous, 71 | Plain { username: String, password: String }, 72 | Jwt { token: String }, 73 | } 74 | 75 | impl Connection { 76 | pub async fn new( 77 | websocket_url: &str, 78 | xmpp_domain: &str, 79 | authentication: Authentication, 80 | room_name: &str, 81 | tls_insecure: bool, 82 | ) -> Result<(Self, impl Future)> { 83 | let websocket_url: Uri = match &authentication { 84 | Authentication::Plain { .. } => websocket_url.parse().context("invalid WebSocket URL")?, 85 | Authentication::Jwt { token } => { 86 | format!("{}?room={}&token={}", websocket_url, room_name, token) 87 | .parse() 88 | .context("invalid WebSocket URL")? 89 | }, 90 | Authentication::Anonymous => websocket_url.parse().context("invalid WebSocket URL")?, 91 | }; 92 | let xmpp_domain: BareJid = xmpp_domain.parse().context("invalid XMPP domain")?; 93 | 94 | info!("Connecting XMPP WebSocket to {}", websocket_url); 95 | let mut key = [0u8; 16]; 96 | thread_rng().fill_bytes(&mut key); 97 | let request = Request::get(&websocket_url) 98 | .header("sec-websocket-protocol", "xmpp") 99 | .header("sec-websocket-key", base64::encode(&key)) 100 | .header("sec-websocket-version", "13") 101 | .header( 102 | "host", 103 | websocket_url 104 | .host() 105 | .context("invalid WebSocket URL: missing host")?, 106 | ) 107 | .header("connection", "Upgrade") 108 | .header("upgrade", "websocket") 109 | .body(()) 110 | .context("failed to build WebSocket request")?; 111 | let (websocket, _response) = tokio_tungstenite::connect_async_tls_with_config( 112 | request, 113 | None, 114 | true, 115 | Some(wss_connector(tls_insecure).context("failed to build TLS connector")?), 116 | ) 117 | .await 118 | .context("failed to connect XMPP WebSocket")?; 119 | let (sink, stream) = websocket.split(); 120 | let (tx, rx) = mpsc::channel(64); 121 | 122 | let inner = Arc::new(Mutex::new(ConnectionInner { 123 | state: ConnectionState::OpeningPreAuthentication, 124 | jid: None, 125 | xmpp_domain, 126 | authentication, 127 | external_services: vec![], 128 | connected_tx: None, 129 | stanza_filters: vec![], 130 | })); 131 | 132 | let connection = Self { 133 | tx: tx.clone(), 134 | inner: inner.clone(), 135 | tls_insecure, 136 | }; 137 | 138 | let writer = Connection::write_loop(rx, sink); 139 | let reader = Connection::read_loop(inner, tx, stream); 140 | 141 | let background = async move { 142 | tokio::select! { 143 | res = reader => if let Err(e) = res { error!("fatal (in read loop): {:?}", e) }, 144 | res = writer => if let Err(e) = res { error!("fatal (in write loop): {:?}", e) }, 145 | } 146 | }; 147 | 148 | Ok((connection, background)) 149 | } 150 | 151 | pub async fn add_stanza_filter(&self, stanza_filter: impl StanzaFilter + Send + Sync + 'static) { 152 | let mut locked_inner = self.inner.lock().await; 153 | locked_inner.stanza_filters.push(Box::new(stanza_filter)); 154 | } 155 | 156 | pub async fn connect(&self) -> Result<()> { 157 | let (tx, rx) = oneshot::channel(); 158 | 159 | { 160 | let mut locked_inner = self.inner.lock().await; 161 | locked_inner.connected_tx = Some(tx); 162 | let open = Open::new(locked_inner.xmpp_domain.clone()); 163 | self.tx.send(open.into()).await?; 164 | } 165 | 166 | rx.await? 167 | } 168 | 169 | pub async fn jid(&self) -> Option { 170 | let locked_inner = self.inner.lock().await; 171 | locked_inner.jid.clone() 172 | } 173 | 174 | pub async fn external_services(&self) -> Vec { 175 | let locked_inner = self.inner.lock().await; 176 | locked_inner.external_services.clone() 177 | } 178 | 179 | async fn write_loop(rx: mpsc::Receiver, mut sink: S) -> Result<()> 180 | where 181 | S: Sink + Unpin, 182 | S::Error: std::error::Error + Send + Sync + 'static, 183 | { 184 | let mut rx = ReceiverStream::new(rx); 185 | while let Some(element) = rx.next().await { 186 | let mut bytes = Vec::new(); 187 | element.write_to(&mut bytes)?; 188 | let xml = String::from_utf8(bytes)?; 189 | #[cfg(feature = "syntax-highlighting")] 190 | { 191 | let ps = syntect::parsing::SyntaxSet::load_defaults_newlines(); 192 | let ts = syntect::highlighting::ThemeSet::load_defaults(); 193 | let syntax = ps.find_syntax_by_extension("xml").unwrap(); 194 | let mut h = syntect::easy::HighlightLines::new(syntax, &ts.themes["Solarized (dark)"]); 195 | let ranges: Vec<_> = h.highlight_line(&xml, &ps).unwrap(); 196 | let escaped = syntect::util::as_24_bit_terminal_escaped(&ranges[..], false); 197 | debug!("XMPP \x1b[32;1m>>> {}\x1b[0m", escaped); 198 | } 199 | #[cfg(not(feature = "syntax-highlighting"))] 200 | debug!("XMPP >>> {}", xml); 201 | sink.send(Message::Text(xml)).await?; 202 | } 203 | Ok(()) 204 | } 205 | 206 | async fn read_loop( 207 | inner: Arc>, 208 | tx: mpsc::Sender, 209 | mut stream: S, 210 | ) -> Result<()> 211 | where 212 | S: Stream> + Unpin, 213 | { 214 | loop { 215 | let message = stream 216 | .try_next() 217 | .await? 218 | .ok_or_else(|| anyhow!("unexpected EOF"))?; 219 | let element: Element = match message { 220 | Message::Text(xml) => { 221 | #[cfg(feature = "syntax-highlighting")] 222 | { 223 | let ps = syntect::parsing::SyntaxSet::load_defaults_newlines(); 224 | let ts = syntect::highlighting::ThemeSet::load_defaults(); 225 | let syntax = ps.find_syntax_by_extension("xml").unwrap(); 226 | let mut h = syntect::easy::HighlightLines::new(syntax, &ts.themes["Solarized (dark)"]); 227 | let ranges: Vec<_> = h.highlight_line(&xml, &ps).unwrap(); 228 | let escaped = syntect::util::as_24_bit_terminal_escaped(&ranges[..], false); 229 | debug!("XMPP \x1b[31;1m<<< {}\x1b[0m", escaped); 230 | } 231 | #[cfg(not(feature = "syntax-highlighting"))] 232 | debug!("XMPP <<< {}", xml); 233 | xml.parse()? 234 | }, 235 | _ => { 236 | warn!( 237 | "unexpected non-text message on XMPP WebSocket stream: {:?}", 238 | message 239 | ); 240 | continue; 241 | }, 242 | }; 243 | 244 | let mut locked_inner = inner.lock().await; 245 | 246 | use ConnectionState::*; 247 | match locked_inner.state { 248 | OpeningPreAuthentication => { 249 | Open::try_from(element)?; 250 | info!("Connected XMPP WebSocket"); 251 | locked_inner.state = ReceivingFeaturesPreAuthentication; 252 | }, 253 | ReceivingFeaturesPreAuthentication => { 254 | let auth = match &locked_inner.authentication { 255 | Authentication::Anonymous => Auth { 256 | mechanism: Mechanism::Anonymous, 257 | data: vec![], 258 | }, 259 | Authentication::Plain { username, password } => { 260 | let mut data = Vec::with_capacity(username.len() + password.len() + 2); 261 | data.push(0u8); 262 | data.extend_from_slice(username.as_bytes()); 263 | data.push(0u8); 264 | data.extend_from_slice(password.as_bytes()); 265 | Auth { 266 | mechanism: Mechanism::Plain, 267 | data, 268 | } 269 | }, 270 | Authentication::Jwt { .. } => Auth { 271 | mechanism: Mechanism::Anonymous, 272 | data: vec![], 273 | }, 274 | }; 275 | tx.send(auth.into()).await?; 276 | locked_inner.state = Authenticating; 277 | }, 278 | Authenticating => { 279 | Success::try_from(element)?; 280 | 281 | let open = Open::new(locked_inner.xmpp_domain.clone()); 282 | tx.send(open.into()).await?; 283 | locked_inner.state = OpeningPostAuthentication; 284 | }, 285 | OpeningPostAuthentication => { 286 | Open::try_from(element)?; 287 | match &locked_inner.authentication { 288 | Authentication::Anonymous => info!("Logged in anonymously"), 289 | Authentication::Plain { .. } => info!("Logged in with PLAIN"), 290 | Authentication::Jwt { .. } => info!("Logged in with JWT"), 291 | } 292 | locked_inner.state = ReceivingFeaturesPostAuthentication; 293 | }, 294 | ReceivingFeaturesPostAuthentication => { 295 | let iq = Iq::from_set(generate_id(), BindQuery::new(None)); 296 | tx.send(iq.into()).await?; 297 | locked_inner.state = Binding; 298 | }, 299 | Binding => match Iq::try_from(element) { 300 | Ok(iq) => { 301 | let jid = if let IqType::Result(Some(element)) = iq.payload { 302 | let bind = BindResponse::try_from(element)?; 303 | FullJid::try_from(bind)? 304 | } 305 | else { 306 | bail!("bind failed"); 307 | }; 308 | info!("My JID: {}", jid); 309 | locked_inner.jid = Some(jid.clone()); 310 | 311 | locked_inner 312 | .stanza_filters 313 | .push(Box::new(Pinger::new(jid.clone(), tx.clone()))); 314 | 315 | let iq = Iq::from_get(generate_id(), DiscoInfoQuery { node: None }) 316 | .with_from(Jid::Full(jid.clone())) 317 | .with_to(Jid::Bare(locked_inner.xmpp_domain.clone())); 318 | tx.send(iq.into()).await?; 319 | locked_inner.state = Discovering; 320 | }, 321 | Err(e) => debug!( 322 | "received unexpected element while waiting for bind response: {}", 323 | e 324 | ), 325 | }, 326 | Discovering => { 327 | let iq = Iq::try_from(element)?; 328 | if let IqType::Result(Some(element)) = iq.payload { 329 | let _disco_info = DiscoInfoResult::try_from(element)?; 330 | } 331 | else { 332 | bail!("disco failed"); 333 | } 334 | 335 | let iq = Iq::from_get(generate_id(), xmpp::extdisco::ServicesQuery {}) 336 | .with_from(Jid::Full( 337 | locked_inner.jid.as_ref().context("missing jid")?.clone(), 338 | )) 339 | .with_to(Jid::Bare(locked_inner.xmpp_domain.clone())); 340 | tx.send(iq.into()).await?; 341 | locked_inner.state = DiscoveringExternalServices; 342 | }, 343 | DiscoveringExternalServices => { 344 | let iq = Iq::try_from(element)?; 345 | if let IqType::Result(Some(element)) = iq.payload { 346 | let services = xmpp::extdisco::ServicesResult::try_from(element)?; 347 | debug!("external services: {:?}", services.services); 348 | locked_inner.external_services = services.services; 349 | } 350 | else { 351 | warn!("discovering external services failed: STUN/TURN will not work"); 352 | } 353 | 354 | if let Some(tx) = locked_inner.connected_tx.take() { 355 | tx.send(Ok(())).map_err(|_| anyhow!("channel closed"))?; 356 | } 357 | locked_inner.state = Idle; 358 | }, 359 | Idle => { 360 | for filter in &locked_inner.stanza_filters { 361 | if filter.filter(&element) { 362 | filter.take(element).await?; 363 | break; 364 | } 365 | } 366 | }, 367 | } 368 | } 369 | } 370 | } 371 | -------------------------------------------------------------------------------- /gst-meet/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::{collections::HashMap, time::Duration}; 2 | 3 | use anyhow::{bail, Context, Result}; 4 | #[cfg(target_os = "macos")] 5 | use cocoa::appkit::NSApplication; 6 | use colibri::{ColibriMessage, Constraints, VideoType}; 7 | use glib::object::ObjectExt as _; 8 | use gstreamer::{ 9 | prelude::{ElementExt as _, ElementExtManual as _, GstBinExt as _}, 10 | GhostPad, 11 | }; 12 | use http::Uri; 13 | use lib_gst_meet::{ 14 | init_tracing, Authentication, Connection, JitsiConference, JitsiConferenceConfig, MediaType, 15 | }; 16 | use structopt::StructOpt; 17 | use tokio::{signal::ctrl_c, task, time::timeout}; 18 | use tracing::{error, info, trace, warn}; 19 | 20 | #[derive(Debug, Clone, StructOpt)] 21 | #[structopt( 22 | name = "gst-meet", 23 | about = "Connect a GStreamer pipeline to a Jitsi Meet conference." 24 | )] 25 | struct Opt { 26 | #[structopt(long)] 27 | web_socket_url: String, 28 | 29 | #[structopt( 30 | long, 31 | help = "If not specified, assumed to be the host part of " 32 | )] 33 | xmpp_domain: Option, 34 | 35 | #[structopt(long)] 36 | room_name: String, 37 | 38 | #[structopt( 39 | long, 40 | help = "If not specified, assumed to be conference." 41 | )] 42 | muc_domain: Option, 43 | 44 | #[structopt( 45 | long, 46 | help = "If not specified, assumed to be focus@auth./focus" 47 | )] 48 | focus_jid: Option, 49 | 50 | #[structopt(long, help = "If not specified, anonymous auth is used.")] 51 | xmpp_username: Option, 52 | 53 | #[structopt(long)] 54 | xmpp_password: Option, 55 | 56 | #[structopt(long, help = "The JWT token for Jitsi JWT authentication")] 57 | xmpp_jwt: Option, 58 | 59 | #[structopt( 60 | long, 61 | default_value = "vp8", 62 | help = "The codec to transmit and receive video using. One of: av1, vp9, vp8, h264" 63 | )] 64 | video_codec: String, 65 | 66 | #[structopt(long, default_value = "gst-meet")] 67 | nick: String, 68 | 69 | #[structopt(long)] 70 | region: Option, 71 | 72 | #[structopt(long)] 73 | send_pipeline: Option, 74 | 75 | #[structopt( 76 | long, 77 | help = "A GStreamer pipeline which will be instantiated at startup. If an element named 'audio' is found, every remote participant's audio will be linked to it (and any 'audio' element in the recv-pipeline-participant-template will be ignored). If an element named 'video' is found, every remote participant's video will be linked to it (and any 'video' element in the recv-pipeline-participant-template will be ignored)." 78 | )] 79 | recv_pipeline: Option, 80 | 81 | #[structopt( 82 | long, 83 | help = "A GStreamer pipeline which will be instantiated for each remote participant. If an element named 'audio' is found, the participant's audio will be linked to it. If an element named 'video' is found, the participant's video will be linked to it." 84 | )] 85 | recv_pipeline_participant_template: Option, 86 | 87 | #[structopt( 88 | long, 89 | help = "Comma-separated endpoint IDs to select (prioritise receiving of)" 90 | )] 91 | select_endpoints: Option, 92 | 93 | #[structopt( 94 | long, 95 | help = "The maximum number of video streams we would like to receive" 96 | )] 97 | last_n: Option, 98 | 99 | #[structopt( 100 | long, 101 | default_value = "720", 102 | help = "The maximum height we plan to send video at (used for stats only)." 103 | )] 104 | send_video_height: u16, 105 | 106 | #[structopt( 107 | long, 108 | help = "The video type to signal that we are sending. One of: camera, desktop" 109 | )] 110 | video_type: Option, 111 | 112 | #[structopt( 113 | long, 114 | default_value = "1280", 115 | help = "The width to scale received video to before passing it to the recv-pipeline." 116 | )] 117 | recv_video_scale_width: u16, 118 | 119 | #[structopt( 120 | long, 121 | default_value = "720", 122 | help = "The height to scale received video to before passing it to the recv-pipeline. This will also be signalled as the maximum height that JVB should send video to us at." 123 | )] 124 | recv_video_scale_height: u16, 125 | 126 | #[structopt( 127 | long, 128 | default_value = "200", 129 | help = "The size of the jitter buffers in milliseconds. Larger values are more resilient to packet loss and jitter, smaller values give lower latency." 130 | )] 131 | buffer_size: u32, 132 | 133 | #[structopt(long)] 134 | start_bitrate: Option, 135 | 136 | #[structopt(long)] 137 | stereo: Option, 138 | 139 | #[structopt(short, long, parse(from_occurrences))] 140 | verbose: u8, 141 | 142 | #[cfg(feature = "tls-insecure")] 143 | #[structopt( 144 | long, 145 | help = "Disable TLS certificate verification (use with extreme caution)" 146 | )] 147 | tls_insecure: bool, 148 | 149 | #[cfg(feature = "log-rtp")] 150 | #[structopt(long, help = "Log all RTP packets at DEBUG level (extremely verbose)")] 151 | log_rtp: bool, 152 | 153 | #[cfg(feature = "log-rtp")] 154 | #[structopt(long, help = "Log all RTCP packets at DEBUG level")] 155 | log_rtcp: bool, 156 | } 157 | 158 | #[cfg(not(target_os = "macos"))] 159 | #[tokio::main] 160 | async fn main() -> Result<()> { 161 | main_inner().await 162 | } 163 | 164 | #[cfg(target_os = "macos")] 165 | fn main() { 166 | // GStreamer requires an NSApp event loop in order for osxvideosink etc to work. 167 | let app = unsafe { cocoa::appkit::NSApp() }; 168 | 169 | let rt = tokio::runtime::Builder::new_multi_thread() 170 | .enable_all() 171 | .build() 172 | .unwrap(); 173 | 174 | rt.spawn(async move { 175 | if let Err(e) = main_inner().await { 176 | error!("fatal: {:?}", e); 177 | } 178 | unsafe { 179 | cocoa::appkit::NSApp().stop_(cocoa::base::nil); 180 | } 181 | std::process::exit(0); 182 | }); 183 | 184 | unsafe { 185 | app.run(); 186 | } 187 | } 188 | 189 | fn init_gstreamer() -> Result<()> { 190 | trace!("starting gstreamer init"); 191 | gstreamer::init()?; 192 | trace!("finished gstreamer init"); 193 | Ok(()) 194 | } 195 | 196 | async fn main_inner() -> Result<()> { 197 | let opt = Opt::from_args(); 198 | 199 | init_tracing(match opt.verbose { 200 | 0 => tracing::Level::INFO, 201 | 1 => tracing::Level::DEBUG, 202 | _ => tracing::Level::TRACE, 203 | }); 204 | glib::log_set_default_handler(glib::rust_log_handler); 205 | 206 | init_gstreamer()?; 207 | 208 | // Parse pipelines early so that we don't bother connecting to the conference if it's invalid. 209 | 210 | let send_pipeline = opt 211 | .send_pipeline 212 | .as_ref() 213 | .map(|pipeline| gstreamer::parse::bin_from_description(pipeline, false)) 214 | .transpose() 215 | .context("failed to parse send pipeline")?; 216 | 217 | let recv_pipeline = opt 218 | .recv_pipeline 219 | .as_ref() 220 | .map(|pipeline| gstreamer::parse::bin_from_description(pipeline, false)) 221 | .transpose() 222 | .context("failed to parse recv pipeline")?; 223 | 224 | let mut web_socket_url: Uri = opt.web_socket_url.parse()?; 225 | let mut web_socket_url_parts = web_socket_url.into_parts(); 226 | web_socket_url_parts.path_and_query = web_socket_url_parts 227 | .path_and_query 228 | .map(|path_and_query| { 229 | let mut qs: HashMap = path_and_query 230 | .query() 231 | .map(serde_urlencoded::from_str) 232 | .transpose()? 233 | .unwrap_or_default(); 234 | if !qs.contains_key("room") { 235 | qs.insert("room".to_owned(), opt.room_name.clone()); 236 | } 237 | Ok::<_, anyhow::Error>( 238 | format!( 239 | "{}?{}", 240 | path_and_query.path(), 241 | serde_urlencoded::to_string(&qs)?, 242 | ) 243 | .parse()?, 244 | ) 245 | }) 246 | .transpose()?; 247 | 248 | web_socket_url = Uri::from_parts(web_socket_url_parts)?; 249 | 250 | let xmpp_domain = opt 251 | .xmpp_domain 252 | .as_deref() 253 | .or_else(|| web_socket_url.host()) 254 | .context("invalid WebSocket URL")?; 255 | 256 | let (connection, background) = Connection::new( 257 | &web_socket_url.to_string(), 258 | xmpp_domain, 259 | match opt.xmpp_username { 260 | Some(username) => Authentication::Plain { 261 | username, 262 | password: opt 263 | .xmpp_password 264 | .context("if xmpp-username is provided, xmpp-password must also be provided")?, 265 | }, 266 | None => match opt.xmpp_jwt { 267 | Some(token) => Authentication::Jwt { token }, 268 | None => Authentication::Anonymous, 269 | }, 270 | }, 271 | &opt.room_name, 272 | #[cfg(feature = "tls-insecure")] 273 | opt.tls_insecure, 274 | #[cfg(not(feature = "tls-insecure"))] 275 | false, 276 | ) 277 | .await 278 | .context("failed to build connection")?; 279 | 280 | tokio::spawn(background); 281 | 282 | connection.connect().await?; 283 | 284 | let room_jid = format!( 285 | "{}@{}", 286 | opt.room_name, 287 | opt 288 | .muc_domain 289 | .clone() 290 | .unwrap_or_else(|| { format!("conference.{}", xmpp_domain) }), 291 | ); 292 | 293 | let focus_jid = opt 294 | .focus_jid 295 | .clone() 296 | .unwrap_or_else(|| format!("focus@auth.{}/focus", xmpp_domain)); 297 | 298 | let Opt { 299 | nick, 300 | region, 301 | video_codec, 302 | recv_pipeline_participant_template, 303 | send_video_height, 304 | recv_video_scale_height, 305 | recv_video_scale_width, 306 | buffer_size, 307 | start_bitrate, 308 | stereo, 309 | #[cfg(feature = "log-rtp")] 310 | log_rtp, 311 | #[cfg(feature = "log-rtp")] 312 | log_rtcp, 313 | .. 314 | } = opt; 315 | 316 | let config = JitsiConferenceConfig { 317 | muc: room_jid.parse()?, 318 | focus: focus_jid.parse()?, 319 | nick, 320 | region, 321 | video_codec, 322 | extra_muc_features: vec![], 323 | start_bitrate: start_bitrate.unwrap_or(800), 324 | stereo: stereo.unwrap_or_default(), 325 | recv_video_scale_height, 326 | recv_video_scale_width, 327 | buffer_size, 328 | #[cfg(feature = "log-rtp")] 329 | log_rtp, 330 | #[cfg(feature = "log-rtp")] 331 | log_rtcp, 332 | }; 333 | 334 | let main_loop = glib::MainLoop::new(None, false); 335 | 336 | let conference = JitsiConference::join(connection, main_loop.context(), config) 337 | .await 338 | .context("failed to join conference")?; 339 | 340 | conference 341 | .set_send_resolution(send_video_height.into()) 342 | .await; 343 | 344 | conference 345 | .send_colibri_message(ColibriMessage::ReceiverVideoConstraints { 346 | last_n: Some(opt.last_n.map(i32::from).unwrap_or(-1)), 347 | selected_endpoints: opt 348 | .select_endpoints 349 | .map(|endpoints| endpoints.split(',').map(ToOwned::to_owned).collect()), 350 | on_stage_endpoints: None, 351 | default_constraints: Some(Constraints { 352 | max_height: Some(opt.recv_video_scale_height.into()), 353 | ideal_height: None, 354 | }), 355 | constraints: None, 356 | }) 357 | .await?; 358 | 359 | if let Some(video_type) = opt.video_type { 360 | conference 361 | .send_colibri_message(ColibriMessage::VideoTypeMessage { 362 | video_type: match video_type.as_str() { 363 | "camera" => VideoType::Camera, 364 | "desktop" => VideoType::Desktop, 365 | other => bail!(format!("invalid video type: {}", other)), 366 | }, 367 | }) 368 | .await?; 369 | } 370 | 371 | if let Some(bin) = send_pipeline { 372 | conference.add_bin(&bin).await?; 373 | 374 | if let Some(audio) = bin.by_name("audio") { 375 | info!("Found audio element in pipeline, linking..."); 376 | let audio_sink = conference.audio_sink_element().await?; 377 | audio.link(&audio_sink)?; 378 | } 379 | else { 380 | conference.set_muted(MediaType::Audio, true).await?; 381 | } 382 | 383 | if let Some(video) = bin.by_name("video") { 384 | info!("Found video element in pipeline, linking..."); 385 | let video_sink = conference.video_sink_element().await?; 386 | video.link(&video_sink)?; 387 | } 388 | else { 389 | conference.set_muted(MediaType::Video, true).await?; 390 | } 391 | } 392 | else { 393 | conference.set_muted(MediaType::Audio, true).await?; 394 | conference.set_muted(MediaType::Video, true).await?; 395 | } 396 | 397 | if let Some(bin) = recv_pipeline { 398 | conference.add_bin(&bin).await?; 399 | 400 | if let Some(audio_element) = bin.by_name("audio") { 401 | info!( 402 | "recv pipeline has an audio element, a sink pad will be requested from it for each participant" 403 | ); 404 | conference 405 | .set_remote_participant_audio_sink_element(Some(audio_element)) 406 | .await; 407 | } 408 | 409 | if let Some(video_element) = bin.by_name("video") { 410 | info!( 411 | "recv pipeline has a video element, a sink pad will be requested from it for each participant" 412 | ); 413 | conference 414 | .set_remote_participant_video_sink_element(Some(video_element)) 415 | .await; 416 | } 417 | } 418 | 419 | conference 420 | .on_participant(move |conference, participant| { 421 | let recv_pipeline_participant_template = recv_pipeline_participant_template.clone(); 422 | Box::pin(async move { 423 | info!("New participant: {:?}", participant); 424 | 425 | if let Some(template) = recv_pipeline_participant_template { 426 | let pipeline_description = template 427 | .replace( 428 | "{jid}", 429 | &participant 430 | .jid 431 | .as_ref() 432 | .map(|jid| jid.to_string()) 433 | .unwrap_or_default(), 434 | ) 435 | .replace( 436 | "{jid_user}", 437 | participant 438 | .jid 439 | .as_ref() 440 | .and_then(|jid| jid.node_str()) 441 | .unwrap_or_default(), 442 | ) 443 | .replace("{participant_id}", &participant.muc_jid.resource_str()) 444 | .replace("{nick}", &participant.nick.unwrap_or_default()); 445 | 446 | let bin = gstreamer::parse::bin_from_description(&pipeline_description, false) 447 | .context("failed to parse recv pipeline participant template")?; 448 | 449 | if let Some(audio_sink_element) = bin.by_name("audio") { 450 | let sink_pad = audio_sink_element.static_pad("sink").context( 451 | "audio sink element in recv pipeline participant template has no sink pad", 452 | )?; 453 | bin.add_pad( 454 | &GhostPad::builder_with_target(&sink_pad)? 455 | .name("audio") 456 | .build(), 457 | )?; 458 | } 459 | 460 | if let Some(video_sink_element) = bin.by_name("video") { 461 | let sink_pad = video_sink_element.static_pad("sink").context( 462 | "video sink element in recv pipeline participant template has no sink pad", 463 | )?; 464 | bin.add_pad( 465 | &GhostPad::builder_with_target(&sink_pad)? 466 | .name("video") 467 | .build(), 468 | )?; 469 | } 470 | 471 | bin.set_property( 472 | "name", 473 | format!("participant_{}", participant.muc_jid.resource()), 474 | ); 475 | conference.add_bin(&bin).await?; 476 | } 477 | 478 | Ok(()) 479 | }) 480 | }) 481 | .await; 482 | 483 | conference 484 | .on_participant_left(move |_conference, participant| { 485 | Box::pin(async move { 486 | info!("Participant left: {:?}", participant); 487 | Ok(()) 488 | }) 489 | }) 490 | .await; 491 | 492 | conference 493 | .on_colibri_message(move |_conference, message| { 494 | Box::pin(async move { 495 | info!("Colibri message: {:?}", message); 496 | Ok(()) 497 | }) 498 | }) 499 | .await; 500 | 501 | conference 502 | .set_pipeline_state(gstreamer::State::Playing) 503 | .await?; 504 | 505 | let conference_ = conference.clone(); 506 | let main_loop_ = main_loop.clone(); 507 | tokio::spawn(async move { 508 | ctrl_c().await.unwrap(); 509 | 510 | info!("Exiting..."); 511 | 512 | match timeout(Duration::from_secs(10), conference_.leave()).await { 513 | Ok(Ok(_)) => {}, 514 | Ok(Err(e)) => warn!("Error leaving conference: {:?}", e), 515 | Err(_) => warn!("Timed out leaving conference"), 516 | } 517 | 518 | main_loop_.quit(); 519 | }); 520 | 521 | task::spawn_blocking(move || main_loop.run()).await?; 522 | 523 | Ok(()) 524 | } 525 | --------------------------------------------------------------------------------