Camera resolution and fps settings in a Screen/Camera tab, camera stats in sharing and watching panels, clicking a focused video closes it
Browse files at this commit13ec58dfe30935bea06d7da14eb12e4506b506a1Parent: 040e8d4- feat
- camera resolution and fps settings in a Screen/Camera tab, camera stats in sharing and watching panels, clicking a focused video closes it
7 changed files +159 -85
- crates/client/src/gui.rs +2 -0
- crates/client/src/gui/chat.rs +9 -5
- crates/client/src/gui/share_view.rs +60 -23
- crates/client/src/gui/voice_stats.rs +27 -11
- crates/client/src/net/media.rs +39 -43
- crates/client/src/settings.rs +20 -1
- crates/client/src/share/session.rs +2 -2
crates/client/src/gui.rsmodified+2 -0
| @@ -603,6 +603,7 @@ pub struct Yumush { | |||
| 603 | backups: Vec<BackupInfo>, | 603 | backups: Vec<BackupInfo>, |
| 604 | pending_backup_delete: Option<String>, | 604 | pending_backup_delete: Option<String>, |
| 605 | share_apps: Vec<crate::share::audio::AudioApp>, | 605 | share_apps: Vec<crate::share::audio::AudioApp>, |
| 606 | + share_tab: common::share::Kind, | ||
| 606 | send_order: Arc<tokio::sync::Mutex<()>>, | 607 | send_order: Arc<tokio::sync::Mutex<()>>, |
| 607 | } | 608 | } |
| 608 | 609 | ||
| @@ -662,6 +663,7 @@ impl Yumush { | |||
| 662 | backups: Vec::new(), | 663 | backups: Vec::new(), |
| 663 | pending_backup_delete: None, | 664 | pending_backup_delete: None, |
| 664 | share_apps: Vec::new(), | 665 | share_apps: Vec::new(), |
| 666 | + share_tab: common::share::Kind::Screen, | ||
| 665 | send_order: Default::default(), | 667 | send_order: Default::default(), |
| 666 | }; | 668 | }; |
| 667 | yumush.chat.camera_task = Some(camera_view::ticker(cx)); | 669 | yumush.chat.camera_task = Some(camera_view::ticker(cx)); |
crates/client/src/gui/chat.rsmodified+9 -5
| @@ -253,7 +253,7 @@ pub struct Chat { | |||
| 253 | pub(super) user_volume: Option<UserVolume>, | 253 | pub(super) user_volume: Option<UserVolume>, |
| 254 | pub(super) voice_samples: VecDeque<VoiceSample>, | 254 | pub(super) voice_samples: VecDeque<VoiceSample>, |
| 255 | pub(super) share_sample: ShareSample, | 255 | pub(super) share_sample: ShareSample, |
| 256 | - pub(super) share_loss: HashMap<Id, VecDeque<f32>>, | 256 | + pub(super) share_loss: HashMap<(Id, Kind), VecDeque<f32>>, |
| 257 | pub(super) stats_tab: StatsTab, | 257 | pub(super) stats_tab: StatsTab, |
| 258 | pub(super) ringing: HashSet<Id>, | 258 | pub(super) ringing: HashSet<Id>, |
| 259 | pub(super) ring_task: Option<Task<()>>, | 259 | pub(super) ring_task: Option<Task<()>>, |
| @@ -1167,10 +1167,14 @@ impl Chat { | |||
| 1167 | } | 1167 | } |
| 1168 | 1168 | ||
| 1169 | pub fn record_share(&mut self, sample: ShareSample) { | 1169 | pub fn record_share(&mut self, sample: ShareSample) { |
| 1170 | - self.share_loss | 1170 | + self.share_loss.retain(|key, _| { |
| 1171 | - .retain(|user_id, _| sample.watching.iter().any(|(id, _)| id == user_id)); | 1171 | + sample |
| 1172 | - for (user_id, stats) in &sample.watching { | 1172 | + .watching |
| 1173 | - let history = self.share_loss.entry(*user_id).or_default(); | 1173 | + .iter() |
| 1174 | + .any(|(user_id, kind, _)| (*user_id, *kind) == *key) | ||
| 1175 | + }); | ||
| 1176 | + for (user_id, kind, stats) in &sample.watching { | ||
| 1177 | + let history = self.share_loss.entry((*user_id, *kind)).or_default(); | ||
| 1174 | history.push_back(stats.loss); | 1178 | history.push_back(stats.loss); |
| 1175 | while history.len() > SAMPLE_HISTORY { | 1179 | while history.len() > SAMPLE_HISTORY { |
| 1176 | history.pop_front(); | 1180 | history.pop_front(); |
crates/client/src/gui/share_view.rsmodified+60 -23
| @@ -20,7 +20,9 @@ use gpui_kit::{ | |||
| 20 | slider::{Slider, SliderEvent, SliderState}, | 20 | slider::{Slider, SliderEvent, SliderState}, |
| 21 | switch::Switch, | 21 | switch::Switch, |
| 22 | }, | 22 | }, |
| 23 | - div, img, px, | 23 | + div, img, |
| 24 | + prelude::FluentBuilder as _, | ||
| 25 | + px, | ||
| 24 | }; | 26 | }; |
| 25 | 27 | ||
| 26 | use super::{ | 28 | use super::{ |
| @@ -148,7 +150,7 @@ impl Yumush { | |||
| 148 | change(&mut self.settings.share); | 150 | change(&mut self.settings.share); |
| 149 | settings::save(&self.settings); | 151 | settings::save(&self.settings); |
| 150 | self.network.set_share_settings(&self.settings.share); | 152 | self.network.set_share_settings(&self.settings.share); |
| 151 | - if self.network.sharing() && before.encoding_differs(&self.settings.share) { | 153 | + if self.network.sharing_any() && before.encoding_differs(&self.settings.share) { |
| 152 | let network = self.network.clone(); | 154 | let network = self.network.clone(); |
| 153 | let settings = self.settings.share.clone(); | 155 | let settings = self.settings.share.clone(); |
| 154 | spawn_warn(cx, "share update", async move { | 156 | spawn_warn(cx, "share update", async move { |
| @@ -175,7 +177,16 @@ impl Yumush { | |||
| 175 | } | 177 | } |
| 176 | 178 | ||
| 177 | pub(super) fn set_share_resolution(&mut self, resolution: Resolution, cx: &mut Context<Self>) { | 179 | pub(super) fn set_share_resolution(&mut self, resolution: Resolution, cx: &mut Context<Self>) { |
| 178 | - self.update_share(cx, |settings| settings.top.resolution = resolution); | 180 | + let kind = self.share_tab; |
| 181 | + self.update_share(cx, |settings| match kind { | ||
| 182 | + Kind::Screen => settings.top.resolution = resolution, | ||
| 183 | + Kind::Camera => settings.camera.resolution = resolution, | ||
| 184 | + }); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + pub(super) fn set_share_tab(&mut self, kind: Kind, cx: &mut Context<Self>) { | ||
| 188 | + self.share_tab = kind; | ||
| 189 | + cx.notify(); | ||
| 179 | } | 190 | } |
| 180 | 191 | ||
| 181 | pub(super) fn set_share_codec(&mut self, codec: ShareCodec, cx: &mut Context<Self>) { | 192 | pub(super) fn set_share_codec(&mut self, codec: ShareCodec, cx: &mut Context<Self>) { |
| @@ -183,7 +194,11 @@ impl Yumush { | |||
| 183 | } | 194 | } |
| 184 | 195 | ||
| 185 | pub(super) fn set_share_fps(&mut self, fps: Fps, cx: &mut Context<Self>) { | 196 | pub(super) fn set_share_fps(&mut self, fps: Fps, cx: &mut Context<Self>) { |
| 186 | - self.update_share(cx, |settings| settings.top.fps = fps); | 197 | + let kind = self.share_tab; |
| 198 | + self.update_share(cx, |settings| match kind { | ||
| 199 | + Kind::Screen => settings.top.fps = fps, | ||
| 200 | + Kind::Camera => settings.camera.fps = fps, | ||
| 201 | + }); | ||
| 187 | } | 202 | } |
| 188 | 203 | ||
| 189 | pub(super) fn set_share_audio_mode(&mut self, mode: AudioMode, cx: &mut Context<Self>) { | 204 | pub(super) fn set_share_audio_mode(&mut self, mode: AudioMode, cx: &mut Context<Self>) { |
| @@ -485,11 +500,20 @@ impl Yumush { | |||
| 485 | .occlude() | 500 | .occlude() |
| 486 | .bg(gpui_kit::black()) | 501 | .bg(gpui_kit::black()) |
| 487 | .group("viewer") | 502 | .group("viewer") |
| 488 | - .children( | 503 | + .child( |
| 489 | - viewer | 504 | + div() |
| 490 | - .frame | 505 | + .id("viewer_video") |
| 491 | - .clone() | 506 | + .size_full() |
| 492 | - .map(|frame| img(frame).size_full().object_fit(ObjectFit::Contain)), | 507 | + .on_click({ |
| 508 | + let entity = entity.clone(); | ||
| 509 | + move |_, _, cx| entity.update(cx, |yumush, cx| yumush.close_viewer(cx)) | ||
| 510 | + }) | ||
| 511 | + .children( | ||
| 512 | + viewer | ||
| 513 | + .frame | ||
| 514 | + .clone() | ||
| 515 | + .map(|frame| img(frame).size_full().object_fit(ObjectFit::Contain)), | ||
| 516 | + ), | ||
| 493 | ) | 517 | ) |
| 494 | .child( | 518 | .child( |
| 495 | div() | 519 | div() |
| @@ -498,6 +522,7 @@ impl Yumush { | |||
| 498 | .right_0() | 522 | .right_0() |
| 499 | .bottom_0() | 523 | .bottom_0() |
| 500 | .h(px(44.)) | 524 | .h(px(44.)) |
| 525 | + .on_mouse_up(MouseButton::Left, |_, _, cx| cx.stop_propagation()) | ||
| 501 | .px(px(12.)) | 526 | .px(px(12.)) |
| 502 | .flex() | 527 | .flex() |
| 503 | .items_center() | 528 | .items_center() |
| @@ -560,7 +585,10 @@ pub(super) fn kind_icon(kind: Kind) -> IconName { | |||
| 560 | 585 | ||
| 561 | fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> Div { | 586 | fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> Div { |
| 562 | let settings = &yumush.settings.share; | 587 | let settings = &yumush.settings.share; |
| 563 | - let (resolutions, fps) = share_limits(yumush.network.share_source()); | 588 | + let kind = yumush.share_tab; |
| 589 | + let top = settings.top(kind); | ||
| 590 | + let (resolutions, fps) = share_limits(yumush.network.share_source(kind)); | ||
| 591 | + let screen = kind == Kind::Screen; | ||
| 564 | 592 | ||
| 565 | div() | 593 | div() |
| 566 | .w(px(320.)) | 594 | .w(px(320.)) |
| @@ -573,13 +601,20 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 573 | .border_1() | 601 | .border_1() |
| 574 | .border_color(palette.border) | 602 | .border_color(palette.border) |
| 575 | .bg(palette.panel) | 603 | .bg(palette.panel) |
| 604 | + .child(segmented( | ||
| 605 | + [(Kind::Screen, "Screen"), (Kind::Camera, "Camera")], | ||
| 606 | + kind, | ||
| 607 | + entity, | ||
| 608 | + palette, | ||
| 609 | + Yumush::set_share_tab, | ||
| 610 | + )) | ||
| 576 | .child(field( | 611 | .child(field( |
| 577 | "Resolution", | 612 | "Resolution", |
| 578 | segmented( | 613 | segmented( |
| 579 | RESOLUTIONS | 614 | RESOLUTIONS |
| 580 | .into_iter() | 615 | .into_iter() |
| 581 | .filter(|(resolution, _)| resolutions.contains(resolution)), | 616 | .filter(|(resolution, _)| resolutions.contains(resolution)), |
| 582 | - settings.top.resolution, | 617 | + top.resolution, |
| 583 | entity, | 618 | entity, |
| 584 | palette, | 619 | palette, |
| 585 | Yumush::set_share_resolution, | 620 | Yumush::set_share_resolution, |
| @@ -590,7 +625,7 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 590 | "FPS", | 625 | "FPS", |
| 591 | segmented( | 626 | segmented( |
| 592 | FPS.into_iter().filter(|(value, _)| fps.contains(value)), | 627 | FPS.into_iter().filter(|(value, _)| fps.contains(value)), |
| 593 | - settings.top.fps, | 628 | + top.fps, |
| 594 | entity, | 629 | entity, |
| 595 | palette, | 630 | palette, |
| 596 | Yumush::set_share_fps, | 631 | Yumush::set_share_fps, |
| @@ -611,18 +646,20 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 611 | ), | 646 | ), |
| 612 | palette, | 647 | palette, |
| 613 | )) | 648 | )) |
| 614 | - .child(field( | 649 | + .when(screen, |this| { |
| 615 | - "Audio", | 650 | + this.child(field( |
| 616 | - segmented( | 651 | + "Audio", |
| 617 | - AudioMode::ALL, | 652 | + segmented( |
| 618 | - AudioMode::of(&settings.audio), | 653 | + AudioMode::ALL, |
| 619 | - entity, | 654 | + AudioMode::of(&settings.audio), |
| 655 | + entity, | ||
| 656 | + palette, | ||
| 657 | + Yumush::set_share_audio_mode, | ||
| 658 | + ), | ||
| 620 | palette, | 659 | palette, |
| 621 | - Yumush::set_share_audio_mode, | 660 | + )) |
| 622 | - ), | 661 | + .children(audio_list(entity, yumush, palette)) |
| 623 | - palette, | 662 | + }) |
| 624 | - )) | ||
| 625 | - .children(audio_list(entity, yumush, palette)) | ||
| 626 | } | 663 | } |
| 627 | 664 | ||
| 628 | fn share_limits(source: Option<Source>) -> (Vec<Resolution>, Vec<Fps>) { | 665 | fn share_limits(source: Option<Source>) -> (Vec<Resolution>, Vec<Fps>) { |
crates/client/src/gui/voice_stats.rsmodified+27 -11
| @@ -1,12 +1,15 @@ | |||
| 1 | use std::collections::VecDeque; | 1 | use std::collections::VecDeque; |
| 2 | 2 | ||
| 3 | -use common::{model::Id, share::Layer}; | 3 | +use common::{ |
| 4 | + model::Id, | ||
| 5 | + share::{Kind, Layer}, | ||
| 6 | +}; | ||
| 4 | use gpui_kit::{ | 7 | use gpui_kit::{ |
| 5 | - Context, Div, Entity, FontWeight, Hsla, ParentElement, Styled, div, hsla, | 8 | + Context, Div, Entity, FontWeight, Hsla, ParentElement, Styled, component::Icon, div, hsla, |
| 6 | prelude::FluentBuilder as _, px, | 9 | prelude::FluentBuilder as _, px, |
| 7 | }; | 10 | }; |
| 8 | 11 | ||
| 9 | -use super::{Palette, Yumush, chat::Chat, settings_page::segmented, text}; | 12 | +use super::{Palette, Yumush, chat::Chat, settings_page::segmented, share_view::kind_icon, text}; |
| 10 | use crate::media::decode::Engine; | 13 | use crate::media::decode::Engine; |
| 11 | use crate::share::session::{LayerStats, WatchStats}; | 14 | use crate::share::session::{LayerStats, WatchStats}; |
| 12 | use crate::voice::VoiceSample; | 15 | use crate::voice::VoiceSample; |
| @@ -211,12 +214,13 @@ fn voice_body(samples: &VecDeque<VoiceSample>, palette: Palette) -> Div { | |||
| 211 | })) | 214 | })) |
| 212 | } | 215 | } |
| 213 | 216 | ||
| 214 | -fn sharing_body(layers: &[LayerStats], palette: Palette) -> Div { | 217 | +fn sharing_body(layers: &[(Kind, LayerStats)], palette: Palette) -> Div { |
| 215 | - let upload: u32 = layers.iter().map(|layer| layer.kbps).sum(); | 218 | + let upload: u32 = layers.iter().map(|(_, layer)| layer.kbps).sum(); |
| 216 | column() | 219 | column() |
| 217 | .child(tile_grid([("Upload", format!("{upload} kbps"))], palette)) | 220 | .child(tile_grid([("Upload", format!("{upload} kbps"))], palette)) |
| 218 | - .children(layers.iter().map(|stat| { | 221 | + .children(layers.iter().map(|(kind, stat)| { |
| 219 | row_line( | 222 | row_line( |
| 223 | + *kind, | ||
| 220 | describe(Some(stat.layer), Some(stat.engine)), | 224 | describe(Some(stat.layer), Some(stat.engine)), |
| 221 | format!("{} kbps · {:.0} fps", stat.kbps, stat.fps), | 225 | format!("{} kbps · {:.0} fps", stat.kbps, stat.fps), |
| 222 | palette, | 226 | palette, |
| @@ -224,8 +228,8 @@ fn sharing_body(layers: &[LayerStats], palette: Palette) -> Div { | |||
| 224 | })) | 228 | })) |
| 225 | } | 229 | } |
| 226 | 230 | ||
| 227 | -fn watching_body(watching: &[(Id, WatchStats)], chat: &Chat, palette: Palette) -> Div { | 231 | +fn watching_body(watching: &[(Id, Kind, WatchStats)], chat: &Chat, palette: Palette) -> Div { |
| 228 | - column().children(watching.iter().map(|(user_id, stats)| { | 232 | + column().children(watching.iter().map(|(user_id, kind, stats)| { |
| 229 | let name = chat | 233 | let name = chat |
| 230 | .author(*user_id) | 234 | .author(*user_id) |
| 231 | .map_or_else(|| user_id.to_string(), |user| user.username.clone()); | 235 | .map_or_else(|| user_id.to_string(), |user| user.username.clone()); |
| @@ -237,12 +241,17 @@ fn watching_body(watching: &[(Id, WatchStats)], chat: &Chat, palette: Palette) - | |||
| 237 | ("Keyframes", stats.keyframes.to_string()), | 241 | ("Keyframes", stats.keyframes.to_string()), |
| 238 | ]; | 242 | ]; |
| 239 | column() | 243 | column() |
| 240 | - .child(row_line(name, describe(stats.layer, stats.engine), palette)) | 244 | + .child(row_line( |
| 245 | + *kind, | ||
| 246 | + name, | ||
| 247 | + describe(stats.layer, stats.engine), | ||
| 248 | + palette, | ||
| 249 | + )) | ||
| 241 | .child(tile_grid(tiles, palette)) | 250 | .child(tile_grid(tiles, palette)) |
| 242 | .child(graph( | 251 | .child(graph( |
| 243 | "Loss", | 252 | "Loss", |
| 244 | chat.share_loss | 253 | chat.share_loss |
| 245 | - .get(user_id) | 254 | + .get(&(*user_id, *kind)) |
| 246 | .into_iter() | 255 | .into_iter() |
| 247 | .flatten() | 256 | .flatten() |
| 248 | .map(|loss| { | 257 | .map(|loss| { |
| @@ -277,7 +286,7 @@ fn describe(layer: Option<Layer>, engine: Option<Engine>) -> String { | |||
| 277 | } | 286 | } |
| 278 | } | 287 | } |
| 279 | 288 | ||
| 280 | -fn row_line(left: String, right: String, palette: Palette) -> Div { | 289 | +fn row_line(kind: Kind, left: String, right: String, palette: Palette) -> Div { |
| 281 | div() | 290 | div() |
| 282 | .flex() | 291 | .flex() |
| 283 | .items_center() | 292 | .items_center() |
| @@ -287,6 +296,13 @@ fn row_line(left: String, right: String, palette: Palette) -> Div { | |||
| 287 | .py(px(4.)) | 296 | .py(px(4.)) |
| 288 | .rounded(px(6.)) | 297 | .rounded(px(6.)) |
| 289 | .bg(palette.window) | 298 | .bg(palette.window) |
| 299 | + .child( | ||
| 300 | + Icon::new(kind_icon(kind)) | ||
| 301 | + .w(px(12.)) | ||
| 302 | + .h(px(12.)) | ||
| 303 | + .flex_none() | ||
| 304 | + .text_color(palette.muted), | ||
| 305 | + ) | ||
| 290 | .child( | 306 | .child( |
| 291 | div() | 307 | div() |
| 292 | .flex_1() | 308 | .flex_1() |
crates/client/src/net/media.rsmodified+39 -43
| @@ -13,7 +13,7 @@ use common::{ | |||
| 13 | datagram::{Packet, RELAY_PREFIX}, | 13 | datagram::{Packet, RELAY_PREFIX}, |
| 14 | event::{Event, Media as Down}, | 14 | event::{Event, Media as Down}, |
| 15 | model::Id, | 15 | model::Id, |
| 16 | - share::{Fps, Kind, Quality, Resolution, Source}, | 16 | + share::{Kind, Quality, Source}, |
| 17 | }; | 17 | }; |
| 18 | use quinn::Connection; | 18 | use quinn::Connection; |
| 19 | use tokio::{runtime::Handle, sync::mpsc}; | 19 | use tokio::{runtime::Handle, sync::mpsc}; |
| @@ -36,11 +36,6 @@ const TICK: Duration = Duration::from_secs(1); | |||
| 36 | const WAIT_STEP: Duration = Duration::from_millis(100); | 36 | const WAIT_STEP: Duration = Duration::from_millis(100); |
| 37 | const WAIT_STEPS: u32 = 50; | 37 | const WAIT_STEPS: u32 = 50; |
| 38 | 38 | ||
| 39 | -const CAMERA_TOP: Quality = Quality { | ||
| 40 | - resolution: Resolution::P2160, | ||
| 41 | - fps: Fps::F60, | ||
| 42 | -}; | ||
| 43 | - | ||
| 44 | #[derive(Clone)] | 39 | #[derive(Clone)] |
| 45 | struct Want { | 40 | struct Want { |
| 46 | community_id: Id, | 41 | community_id: Id, |
| @@ -343,10 +338,7 @@ impl Media { | |||
| 343 | 338 | ||
| 344 | async fn start_share(self: Arc<Self>, kind: Kind, settings: ShareSettings) -> Result<(), Fail> { | 339 | async fn start_share(self: Arc<Self>, kind: Kind, settings: ShareSettings) -> Result<(), Fail> { |
| 345 | let (connection, epoch) = self.current_wait().await?; | 340 | let (connection, epoch) = self.current_wait().await?; |
| 346 | - let top = match kind { | 341 | + let top = settings.top(kind); |
| 347 | - Kind::Screen => settings.top, | ||
| 348 | - Kind::Camera => CAMERA_TOP, | ||
| 349 | - }; | ||
| 350 | let sharing = Sharing::start( | 342 | let sharing = Sharing::start( |
| 351 | connection.clone(), | 343 | connection.clone(), |
| 352 | kind, | 344 | kind, |
| @@ -374,24 +366,28 @@ impl Media { | |||
| 374 | } | 366 | } |
| 375 | 367 | ||
| 376 | async fn update_share(self: Arc<Self>, settings: ShareSettings) -> Result<(), Fail> { | 368 | async fn update_share(self: Arc<Self>, settings: ShareSettings) -> Result<(), Fail> { |
| 377 | - let kind = Kind::Screen; | ||
| 378 | let (connection, _) = self.current_wait().await?; | 369 | let (connection, _) = self.current_wait().await?; |
| 379 | - let source = { | 370 | + let sources = { |
| 380 | let mut inner = self.lock(); | 371 | let mut inner = self.lock(); |
| 381 | - let Some(sharing) = inner.sharing.get_mut(&kind) else { | 372 | + let mut sources = Vec::new(); |
| 382 | - return Ok(()); | 373 | + for (kind, sharing) in &mut inner.sharing { |
| 383 | - }; | 374 | + let source = sharing |
| 384 | - sharing | 375 | + .update( |
| 385 | - .update( | 376 | + &connection, |
| 386 | - &connection, | 377 | + settings.top(*kind), |
| 387 | - settings.top, | 378 | + settings.encode(), |
| 388 | - settings.encode(), | 379 | + settings.audio_mode(), |
| 389 | - settings.audio_mode(), | 380 | + ) |
| 390 | - ) | 381 | + .map_err(Fail::Io)?; |
| 391 | - .map_err(Fail::Io)? | 382 | + sources.push((*kind, source)); |
| 383 | + } | ||
| 384 | + sources | ||
| 392 | }; | 385 | }; |
| 386 | + for (kind, source) in sources { | ||
| 387 | + call(&connection, StartShare { kind, source }).await?; | ||
| 388 | + } | ||
| 393 | 389 | ||
| 394 | - call(&connection, StartShare { kind, source }).await | 390 | + Ok(()) |
| 395 | } | 391 | } |
| 396 | 392 | ||
| 397 | async fn stop_share(self: Arc<Self>, kind: Kind) -> Result<(), Fail> { | 393 | async fn stop_share(self: Arc<Self>, kind: Kind) -> Result<(), Fail> { |
| @@ -625,12 +621,12 @@ impl NetworkHandle { | |||
| 625 | self.media().lock().sharing.contains_key(&Kind::Camera) | 621 | self.media().lock().sharing.contains_key(&Kind::Camera) |
| 626 | } | 622 | } |
| 627 | 623 | ||
| 628 | - pub fn share_source(&self) -> Option<Source> { | 624 | + pub fn share_source(&self, kind: Kind) -> Option<Source> { |
| 629 | - self.media() | 625 | + self.media().lock().sharing.get(&kind).map(Sharing::source) |
| 630 | - .lock() | 626 | + } |
| 631 | - .sharing | 627 | + |
| 632 | - .get(&Kind::Screen) | 628 | + pub fn sharing_any(&self) -> bool { |
| 633 | - .map(Sharing::source) | 629 | + !self.media().lock().sharing.is_empty() |
| 634 | } | 630 | } |
| 635 | 631 | ||
| 636 | pub async fn shares(&self, community_id: Id) -> Result<Vec<common::share::Share>, Fail> { | 632 | pub async fn shares(&self, community_id: Id) -> Result<Vec<common::share::Share>, Fail> { |
| @@ -693,19 +689,19 @@ impl NetworkHandle { | |||
| 693 | 689 | ||
| 694 | pub fn share_sample(&self) -> ShareSample { | 690 | pub fn share_sample(&self) -> ShareSample { |
| 695 | let mut inner = self.media().lock(); | 691 | let mut inner = self.media().lock(); |
| 696 | - ShareSample { | 692 | + let mut sending: Vec<_> = inner |
| 697 | - sending: inner | 693 | + .sharing |
| 698 | - .sharing | 694 | + .iter() |
| 699 | - .get(&Kind::Screen) | 695 | + .flat_map(|(kind, sharing)| sharing.stats().into_iter().map(|stat| (*kind, stat))) |
| 700 | - .map(Sharing::stats) | 696 | + .collect(); |
| 701 | - .unwrap_or_default(), | 697 | + sending.sort_by_key(|(kind, _)| *kind == Kind::Camera); |
| 702 | - watching: inner | 698 | + let mut watching: Vec<_> = inner |
| 703 | - .watching | 699 | + .watching |
| 704 | - .iter_mut() | 700 | + .iter_mut() |
| 705 | - .filter(|((_, kind), _)| *kind == Kind::Screen) | 701 | + .map(|((user_id, kind), watching)| (*user_id, *kind, watching.stats())) |
| 706 | - .map(|((user_id, _), watching)| (*user_id, watching.stats())) | 702 | + .collect(); |
| 707 | - .collect(), | 703 | + watching.sort_by_key(|(user_id, kind, _)| (*kind == Kind::Camera, *user_id)); |
| 708 | - } | 704 | + ShareSample { sending, watching } |
| 709 | } | 705 | } |
| 710 | 706 | ||
| 711 | pub fn share_frame(&self, user_id: Id, kind: Kind) -> Option<crate::media::Frame> { | 707 | pub fn share_frame(&self, user_id: Id, kind: Kind) -> Option<crate::media::Frame> { |
crates/client/src/settings.rsmodified+20 -1
| @@ -3,7 +3,7 @@ use std::{collections::BTreeMap, fmt::Display, ops::RangeInclusive}; | |||
| 3 | use common::{ | 3 | use common::{ |
| 4 | config::Config, | 4 | config::Config, |
| 5 | model::Id, | 5 | model::Id, |
| 6 | - share::{Codec, Fps, Quality, Resolution}, | 6 | + share::{Codec, Fps, Kind, Quality, Resolution}, |
| 7 | string_enum, | 7 | string_enum, |
| 8 | }; | 8 | }; |
| 9 | use gpui_kit::{ | 9 | use gpui_kit::{ |
| @@ -19,6 +19,11 @@ use crate::{ | |||
| 19 | write_config, | 19 | write_config, |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | +pub const CAMERA_QUALITY: Quality = Quality { | ||
| 23 | + resolution: Resolution::P720, | ||
| 24 | + fps: Fps::F30, | ||
| 25 | +}; | ||
| 26 | + | ||
| 22 | pub const SHARE_QUALITY: Quality = Quality { | 27 | pub const SHARE_QUALITY: Quality = Quality { |
| 23 | resolution: Resolution::P1080, | 28 | resolution: Resolution::P1080, |
| 24 | fps: Fps::F30, | 29 | fps: Fps::F30, |
| @@ -142,6 +147,7 @@ pub enum ShareCodec { | |||
| 142 | #[derive(Debug, Clone, PartialEq)] | 147 | #[derive(Debug, Clone, PartialEq)] |
| 143 | pub struct ShareSettings { | 148 | pub struct ShareSettings { |
| 144 | pub top: Quality, | 149 | pub top: Quality, |
| 150 | + pub camera: Quality, | ||
| 145 | pub codec: ShareCodec, | 151 | pub codec: ShareCodec, |
| 146 | pub audio: ShareAudio, | 152 | pub audio: ShareAudio, |
| 147 | pub excluded: Vec<String>, | 153 | pub excluded: Vec<String>, |
| @@ -152,6 +158,7 @@ impl Default for ShareSettings { | |||
| 152 | fn default() -> Self { | 158 | fn default() -> Self { |
| 153 | Self { | 159 | Self { |
| 154 | top: SHARE_QUALITY, | 160 | top: SHARE_QUALITY, |
| 161 | + camera: CAMERA_QUALITY, | ||
| 155 | codec: ShareCodec::Auto, | 162 | codec: ShareCodec::Auto, |
| 156 | audio: ShareAudio::Everything, | 163 | audio: ShareAudio::Everything, |
| 157 | excluded: Vec::new(), | 164 | excluded: Vec::new(), |
| @@ -161,8 +168,16 @@ impl Default for ShareSettings { | |||
| 161 | } | 168 | } |
| 162 | 169 | ||
| 163 | impl ShareSettings { | 170 | impl ShareSettings { |
| 171 | + pub fn top(&self, kind: Kind) -> Quality { | ||
| 172 | + match kind { | ||
| 173 | + Kind::Screen => self.top, | ||
| 174 | + Kind::Camera => self.camera, | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + | ||
| 164 | pub fn encoding_differs(&self, other: &Self) -> bool { | 178 | pub fn encoding_differs(&self, other: &Self) -> bool { |
| 165 | self.top != other.top | 179 | self.top != other.top |
| 180 | + || self.camera != other.camera | ||
| 166 | || self.codec != other.codec | 181 | || self.codec != other.codec |
| 167 | || self.audio != other.audio | 182 | || self.audio != other.audio |
| 168 | || self.excluded != other.excluded | 183 | || self.excluded != other.excluded |
| @@ -278,6 +293,9 @@ pub fn load() -> Settings { | |||
| 278 | top: text("share.top") | 293 | top: text("share.top") |
| 279 | .and_then(|value| parse_quality(&value)) | 294 | .and_then(|value| parse_quality(&value)) |
| 280 | .unwrap_or(defaults.share.top), | 295 | .unwrap_or(defaults.share.top), |
| 296 | + camera: text("share.camera") | ||
| 297 | + .and_then(|value| parse_quality(&value)) | ||
| 298 | + .unwrap_or(defaults.share.camera), | ||
| 281 | codec: text("share.codec") | 299 | codec: text("share.codec") |
| 282 | .and_then(|value| Codec::parse(&value)) | 300 | .and_then(|value| Codec::parse(&value)) |
| 283 | .map_or(ShareCodec::Auto, ShareCodec::Only), | 301 | .map_or(ShareCodec::Auto, ShareCodec::Only), |
| @@ -348,6 +366,7 @@ pub fn save(settings: &Settings) { | |||
| 348 | .join(","), | 366 | .join(","), |
| 349 | ), | 367 | ), |
| 350 | line("share.top", quality_text(share.top)), | 368 | line("share.top", quality_text(share.top)), |
| 369 | + line("share.camera", quality_text(share.camera)), | ||
| 351 | line( | 370 | line( |
| 352 | "share.codec", | 371 | "share.codec", |
| 353 | match share.codec { | 372 | match share.codec { |
crates/client/src/share/session.rsmodified+2 -2
| @@ -96,8 +96,8 @@ pub struct WatchStats { | |||
| 96 | 96 | ||
| 97 | #[derive(Default)] | 97 | #[derive(Default)] |
| 98 | pub struct ShareSample { | 98 | pub struct ShareSample { |
| 99 | - pub sending: Vec<LayerStats>, | 99 | + pub sending: Vec<(Kind, LayerStats)>, |
| 100 | - pub watching: Vec<(Id, WatchStats)>, | 100 | + pub watching: Vec<(Id, Kind, WatchStats)>, |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | struct Tally { | 103 | struct Tally { |