Skip to content

Commit

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

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

Large diffs are not rendered by default.

38 changes: 9 additions & 29 deletions yew-ui/src/components/host.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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 @@ -40,31 +38,25 @@ pub struct MeetingProps {
#[prop_or_default]
pub id: String,

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

#[prop_or_default]
pub email: String,
pub client: VideoCallClient,

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

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,
);
self.camera.start();
true
}
Msg::DisableVideo => {
Expand Down
3 changes: 3 additions & 0 deletions yew-ui/src/model/client/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod video_call_client;

pub use video_call_client::{VideoCallClient, VideoCallClientOptions};
Loading

0 comments on commit 1909ae5

Please sign in to comment.