//! `voelinctl connect ... stream start|list|watch`: TeamSpeak 6 streams. use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; use anyhow::{Context, Result, bail}; use clap::{Args, Subcommand}; use futures::prelude::*; use tokio::io::{AsyncBufReadExt, BufReader, Lines, Stdin}; use tokio::time::{Instant, Interval, sleep_until}; use tsclientlib::prelude::*; use tsclientlib::{ClientId, Connection, MessageHandle, StreamItem}; use voelin_core::media::voelin_media::capture::SourceId; use voelin_core::media::voelin_media::{Codecs, VideoFrame, convert}; use voelin_core::media::{ CaptureBackend, EncodedSource, EncoderPreference, Latest, Streamer, StreamerConfig, VideoPipeline, peer_config, preferred_codec, stream_codec, video_codec, }; use voelin_model::ServerFlavor; use voelin_stream::{ ClientState, EndReason, FrameSource, H264Profile, LayerId, LayerSpec, MediaKind, Output, PeerConfig, Request, SrtpProfile, StreamEvent, StreamInfo, StreamNotification, StreamSetup, StreamerEvent, StreamerOptions, Streams, SyntheticSource, VideoCodec, ViewerInfo, WatchEvent, }; #[derive(Args, Debug, Clone)] pub struct StreamArgs { #[command(subcommand)] command: StreamCommand, /// Media over 127.0.0.1 only (both ends on this machine), no STUN. #[arg(long, global = true)] loopback: bool, /// STUN server (`host:port`) for a public candidate; repeatable [default: TeamSpeak's]. #[arg(long, global = true)] stun: Vec, /// Do not use STUN. #[arg(long, global = true, conflicts_with = "stun")] no_stun: bool, /// SRTP profiles in order of preference, comma separated /// (`AES_CM_128_HMAC_SHA1_80`, `AEAD_AES_128_GCM`, `AEAD_AES_256_GCM`) /// [default: in this order]. #[arg(long, global = true, value_delimiter = ',')] srtp: Vec, } #[derive(Subcommand, Debug, Clone)] pub enum StreamCommand { /// Stream in our channel: the screen (VP8) and system audio (Opus). /// Without `--auto-accept`, answer join requests on stdin: `accept /// `, `deny `, `kick `, `stop`. Start { /// Stream name. #[arg(long, default_value = "voelinctl")] name: String, /// What to capture: `synthetic` (a moving test pattern and a tone), /// `x11[:]`, `screen[:]` (this session's backend), /// `window:` or `portal` (the desktop's dialog). #[arg(long, default_value = "screen")] source: String, /// Same as `--source synthetic`. #[arg(long, conflicts_with = "source")] synthetic: bool, /// Size of the test pattern. #[arg(long, default_value = "1280x720")] size: String, /// Accept every viewer. #[arg(long)] auto_accept: bool, /// Stop after this many seconds [default: until Ctrl-C]. #[arg(long)] seconds: Option, /// Video frames per second. #[arg(long, default_value_t = 30)] fps: u32, /// Video bitrate in kbit/s (announced in `setupstream` too). #[arg(long, default_value_t = 4608)] bitrate: u32, /// No audio track. #[arg(long)] no_audio: bool, /// A simulcast layer, repeatable: `:[: