Skip to content

Commit

Permalink
Revert "Factor out connection, peer management, and packet handling i…
Browse files Browse the repository at this point in the history
…nto `VideoCallClient` (#137)" (#148)

This reverts commit bb27fb4.
  • Loading branch information
darioalessandro authored Nov 18, 2023
1 parent 672a732 commit ad6dcc5
Show file tree
Hide file tree
Showing 17 changed files with 421 additions and 640 deletions.
311 changes: 260 additions & 51 deletions yew-ui/src/components/attendants.rs

Large diffs are not rendered by default.

38 changes: 29 additions & 9 deletions yew-ui/src/components/host.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::model::client::VideoCallClient;
use gloo_timers::callback::Timeout;
use log::debug;
use types::protos::packet_wrapper::PacketWrapper;

use std::fmt::Debug;
use std::sync::Arc;
use yew::prelude::*;

use crate::components::device_selector::DeviceSelector;
use crate::crypto::aes::Aes128State;
use crate::model::encode::CameraEncoder;
use crate::model::encode::MicrophoneEncoder;
use crate::model::encode::ScreenEncoder;
Expand Down Expand Up @@ -38,25 +40,31 @@ pub struct MeetingProps {
#[prop_or_default]
pub id: String,

pub client: VideoCallClient,
#[prop_or_default]
pub on_packet: Callback<PacketWrapper>,

#[prop_or_default]
pub email: String,

pub share_screen: bool,

pub mic_enabled: bool,

pub video_enabled: bool,

pub aes: Arc<Aes128State>,
}

impl Component for Host {
type Message = Msg;
type Properties = MeetingProps;

fn create(ctx: &Context<Self>) -> Self {
let client = &ctx.props().client;
let aes = ctx.props().aes.clone();
Self {
camera: CameraEncoder::new(client.clone(), VIDEO_ELEMENT_ID),
microphone: MicrophoneEncoder::new(client.clone()),
screen: ScreenEncoder::new(client.clone()),
camera: CameraEncoder::new(aes.clone()),
microphone: MicrophoneEncoder::new(aes.clone()),
screen: ScreenEncoder::new(aes),
share_screen: ctx.props().share_screen,
mic_enabled: ctx.props().mic_enabled,
video_enabled: ctx.props().video_enabled,
Expand Down Expand Up @@ -99,7 +107,10 @@ impl Component for Host {
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
match msg {
Msg::EnableScreenShare => {
self.screen.start();
let on_frame = ctx.props().on_packet.clone();
let email = ctx.props().email.clone();
self.screen
.start(email, move |packet: PacketWrapper| on_frame.emit(packet));
true
}
Msg::DisableScreenShare => {
Expand All @@ -111,7 +122,10 @@ impl Component for Host {
if !should_enable {
return true;
}
self.microphone.start();
let on_audio = ctx.props().on_packet.clone();
let email = ctx.props().email.clone();
self.microphone
.start(email, move |packet: PacketWrapper| on_audio.emit(packet));
true
}
Msg::DisableMicrophone => {
Expand All @@ -123,7 +137,13 @@ impl Component for Host {
return true;
}

self.camera.start();
let on_packet = ctx.props().on_packet.clone();
let email = ctx.props().email.clone();
self.camera.start(
email,
move |packet: PacketWrapper| on_packet.emit(packet),
VIDEO_ELEMENT_ID,
);
true
}
Msg::DisableVideo => {
Expand Down
3 changes: 0 additions & 3 deletions yew-ui/src/model/client/mod.rs

This file was deleted.

Loading

0 comments on commit ad6dcc5

Please sign in to comment.