| 1 | use std::collections::VecDeque; |
| 2 | |
| 3 | use bitcode::{Decode, Encode}; |
| 4 | |
| 5 | use crate::{ |
| 6 | model::Id, |
| 7 | share::{Kind, Layer}, |
| 8 | }; |
| 9 | |
| 10 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)] |
| 11 | pub enum Engine { |
| 12 | Hardware, |
| 13 | Software, |
| 14 | } |
| 15 | |
| 16 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 17 | pub struct Traffic { |
| 18 | pub jitter_ms: f32, |
| 19 | pub buffer_ms: f32, |
| 20 | pub loss: f32, |
| 21 | pub up_kbps: f32, |
| 22 | pub down_kbps: f32, |
| 23 | } |
| 24 | |
| 25 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 26 | pub struct VoiceSample { |
| 27 | pub at_ms: u64, |
| 28 | pub ping_ms: f32, |
| 29 | pub traffic: Traffic, |
| 30 | pub bitrate_kbps: u32, |
| 31 | } |
| 32 | |
| 33 | #[derive(Debug, Clone, Default, Encode, Decode)] |
| 34 | pub struct Usage { |
| 35 | pub host: String, |
| 36 | pub os: String, |
| 37 | pub cpu_model: String, |
| 38 | pub machine: f32, |
| 39 | pub total: f32, |
| 40 | pub threads: Option<Threads>, |
| 41 | pub memory: Memory, |
| 42 | pub storage: Option<Storage>, |
| 43 | pub gpu: Option<Gpu>, |
| 44 | } |
| 45 | |
| 46 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 47 | pub struct Storage { |
| 48 | pub used_mb: u32, |
| 49 | pub total_mb: u32, |
| 50 | } |
| 51 | |
| 52 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 53 | pub struct Threads { |
| 54 | pub gui: f32, |
| 55 | pub camera: f32, |
| 56 | pub encode: f32, |
| 57 | pub decode: f32, |
| 58 | } |
| 59 | |
| 60 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 61 | pub struct Memory { |
| 62 | pub own_mb: u32, |
| 63 | pub used_mb: u32, |
| 64 | pub total_mb: u32, |
| 65 | } |
| 66 | |
| 67 | #[derive(Debug, Clone, Default, Encode, Decode)] |
| 68 | pub struct Gpu { |
| 69 | pub model: String, |
| 70 | pub gfx: f32, |
| 71 | pub video: f32, |
| 72 | pub vram_mb: u32, |
| 73 | pub machine: GpuMachine, |
| 74 | } |
| 75 | |
| 76 | #[derive(Debug, Clone, Copy, Default, Encode, Decode)] |
| 77 | pub struct GpuMachine { |
| 78 | pub gfx: f32, |
| 79 | pub video: f32, |
| 80 | pub vram_used_mb: u32, |
| 81 | pub vram_total_mb: u32, |
| 82 | } |
| 83 | |
| 84 | #[derive(Debug, Clone, Encode, Decode)] |
| 85 | pub struct LayerStats { |
| 86 | pub layer: Layer, |
| 87 | pub engine: Engine, |
| 88 | pub kbps: u32, |
| 89 | pub fps: f32, |
| 90 | pub gap_ms: (i64, i64), |
| 91 | } |
| 92 | |
| 93 | #[derive(Debug, Clone, Default, Encode, Decode)] |
| 94 | pub struct WatchStats { |
| 95 | pub layer: Option<Layer>, |
| 96 | pub engine: Option<Engine>, |
| 97 | pub kbps: u32, |
| 98 | pub fps: f32, |
| 99 | pub loss: f32, |
| 100 | pub keyframes: u32, |
| 101 | pub buffer_ms: i64, |
| 102 | pub latency_ms: Option<i64>, |
| 103 | pub nacks: u32, |
| 104 | pub shown_fps: f32, |
| 105 | pub dropped: u32, |
| 106 | pub interval_ms: (i64, i64), |
| 107 | pub swing_ms: i64, |
| 108 | } |
| 109 | |
| 110 | #[derive(Debug, Clone, Default, Encode, Decode)] |
| 111 | pub struct ShareSample { |
| 112 | pub sending: Vec<(Kind, LayerStats)>, |
| 113 | pub watching: Vec<(Id, Kind, WatchStats)>, |
| 114 | } |
| 115 | |
| 116 | #[derive(Debug, Clone, Default, Encode, Decode)] |
| 117 | pub struct Stats { |
| 118 | pub voice: VecDeque<VoiceSample>, |
| 119 | pub traffic: VecDeque<(u64, f32, f32)>, |
| 120 | pub usage: Option<Usage>, |
| 121 | pub share: ShareSample, |
| 122 | } |