Skip to content

Commit e2ed0cd

Browse files
committed
Updates to doc
1 parent e0e1843 commit e2ed0cd

File tree

5 files changed

+70
-22
lines changed

5 files changed

+70
-22
lines changed

Documentazione_Capasso-M63001498.pdf

3.83 KB
Binary file not shown.

Makefile

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ build:
1616

1717
## dev: creates nats and postgres container; executes backend and frontend locally
1818
dev:
19-
docker run -d --network=host nats
20-
docker run -d --network=host -e POSTGRES_PASSWORD=postgres postgres
2119
cargo watch -wq backend/ -w common -x "cargo run --bin backend" &
22-
trunk serve &
20+
RUSTFLAGS=--cfg=web_sys_unstable_apis trunk serve
2321

2422
.PHONY: help
2523
## help: prints this help message

backend/src/web/webtransport.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub const WEB_TRANSPORT_ALPN: &[&[u8]] = &[b"h3", b"h3-32", b"h3-31", b"h3-30",
2929

3030
pub const QUIC_ALPN: &[u8] = b"hq-29";
3131

32-
const MAX_UNIDIRECTIONAL_STREAM_SIZE: usize = 500_000;
32+
const MAX_UNIDIRECTIONAL_STREAM_SIZE: usize = 1000_000;
3333

3434
#[derive(Debug)]
3535
pub struct WebTransportOpt {

docs/report/main.tex

+67-17
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ \section*{Introduzione}
7676
\item Eliminazione dell'implementazione mediante websocket;
7777
\item Eliminazione della parte di screen-sharing;
7878
\item Modifica della parte audio per inviare e ricevere audio stereo con codec opus;
79+
\item Aggiunta di una callback per recuperare l'id della sorgente audio selezionata, per
80+
implemente un oscilloscopio;
7981
\end{itemize}
8082

8183
\clearpage
@@ -754,9 +756,10 @@ \subsubsection{Protocollo QUIC} \label{section:quic-protocol}
754756
del codec è riportata in \cref{lst:audio-config}. Successivamente, per rendere effettive le modifiche dal punto
755757
di vista dei dispositivi si è intervenuto sia sull'encoder che sul decoder (situati
756758
rispettivamente nei file \textit{microphone\_encoder.rs} e \textit{config.rs}),
757-
come mostrato \cref{lst:encoder-params} in e \cref{lst:decoder-params} . Infine, per migliorare la latenza, si è
758-
abbasata la dimensione del buffer utilizzato da $100Kb$ a $4Kb$, come mostrato in
759-
\cref{lst:encoder-buffer-size}.
759+
come mostrato \cref{lst:encoder-params} in e \cref{lst:decoder-params}. Infine, per realizzare
760+
il componente AudioVisualizer il cui scopo è quello di fornire un feedback visivo a chi
761+
sta suonando è stata aggiunta una callback per catturare l'evento in cui l'utente cambia
762+
la sorgente del dispositivo (\cref{lst:callback-audio-id}).
760763

761764
\begin{lstlisting}[language=Rust, style=boxed, label={lst:audio-config}, captionpos=b,caption={Configurazione utilizzata per trasmettere l'audio}]
762765
pub static AUDIO_CODEC: &str = "opus";
@@ -811,20 +814,31 @@ \subsubsection{Protocollo QUIC} \label{section:quic-protocol}
811814

812815
\end{lstlisting}
813816

814-
815-
\begin{lstlisting}[language=Rust, style=boxed, label={lst:encoder-buffer-size}, captionpos=b,caption={Riduzione del buffer size per l'encoder OPUS}]
816-
let audio_output_handler = {
817-
let mut buffer: [u8; 4096] = [0; 4096];
818-
let mut sequence = 0;
819-
Box::new(move |chunk: JsValue| {
820-
let chunk = web_sys::EncodedAudioChunk::from(chunk);
821-
let packet: PacketWrapper =
822-
transform_audio_chunk(&chunk, &mut buffer, &userid, sequence, aes.clone());
823-
client.send_packet(packet);
824-
sequence += 1;
825-
})
826-
};
827-
817+
\begin{lstlisting}[language=Rust, style=boxed, label={lst:callback-audio-id}, captionpos=b,caption={Modifica del file host.rs per invocare la callback}]
818+
pub enum Msg {
819+
WsAction(WsAction),
820+
MeetingAction(MeetingAction),
821+
OnPeerAdded(String),
822+
OnFirstFrame((String, MediaType)),
823+
// aggiunta callback per ricavare l'id della sorgente audio
824+
OnChangeMic(String),
825+
}
826+
// file host.rs
827+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
828+
match msg {
829+
// invocazione della callback dichiarata in precedenza
830+
Msg::AudioDeviceChanged(audio) => {
831+
if self.microphone.select(audio.clone()) {
832+
let link = ctx.link().clone();
833+
let timeout = Timeout::new(1000, move || {
834+
link.send_message(Msg::EnableMicrophone(true));
835+
});
836+
timeout.forget();
837+
}
838+
self.on_audio_src_changed.emit(audio);
839+
false
840+
}
841+
}
828842
\end{lstlisting}
829843

830844
\subsubsection{Serializzazione binaria: protocol buffer}
@@ -1238,6 +1252,42 @@ \subsection{Test dell'applicazione}
12381252
\caption{Selezione della sorgente audio nell'applicazione}\label{fig:selecting-vmic}
12391253
\end{figure}
12401254

1255+
\paragraph{Performance}L'applicazione è intesa da utilizzare con dispositivi hardware (interfacce audio)
1256+
con cui effettuare gran parte del workload con cui effettuare DSP. La demo con dispositivi virtuali serve
1257+
a dimostrare il funzionamento, ma è possibile riscontrare bassa qualità dell'audio e fenomeni di glitch/distorsioni.
1258+
Per rilassare lo stress sulla CPU è possibile aumentare la dimensione del buffer dell'encoder (aumentando una
1259+
possibile latenza). Il buffer (microphone\_encoder.rs della libreria videocall-client \cref{lst:encoder-size}) può essere aumentato
1260+
in accordo con le dimensioni dell'head messo a disposizione dalla macchina WebAssembly (circa $500\_000$ byte)
1261+
oltre al quale si ottiene un errore di accesso in memoria.
1262+
1263+
\begin{lstlisting}[language=Rust, style=boxed, label={lst:encoder-size}, captionpos=b,caption={Dimensione del buffer per l'encoder OPUS}]
1264+
pub fn start(&mut self) {
1265+
let device_id = if let Some(mic) = &self.state.selected {
1266+
mic.to_string()
1267+
} else {
1268+
return;
1269+
};
1270+
let client = self.client.clone();
1271+
let userid = client.userid().clone();
1272+
let aes = client.aes();
1273+
let audio_output_handler = {
1274+
let mut buffer: [u8; 500000] = [0; 500000];
1275+
let mut sequence = 0;
1276+
Box::new(move |chunk: JsValue| {
1277+
let chunk = web_sys::EncodedAudioChunk::from(chunk);
1278+
let packet: PacketWrapper =
1279+
transform_audio_chunk(&chunk, &mut buffer, &userid, sequence, aes.clone());
1280+
client.send_packet(packet);
1281+
sequence += 1;
1282+
})
1283+
};
1284+
let EncoderState {
1285+
destroy,
1286+
enabled,
1287+
switching,
1288+
..
1289+
} = self.state.clone();
1290+
\end{lstlisting}
12411291
\clearpage
12421292

12431293

launch_chrome.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo $SPKI
1111
echo "Opening google chrome"
1212

1313
case $(uname) in
14-
(*Linux*) brave --origin-to-force-quic-on=127.0.0.1:4433 --ignore-certificate-errors-spki-list="$SPKI" --enable-logging --v=1 ;;
14+
(*Linux*) chromium --origin-to-force-quic-on=127.0.0.1:4433 --ignore-certificate-errors-spki-list="$SPKI" --enable-logging --v=1 ;;
1515
(*Darwin*) open -a "Google Chrome" --args --origin-to-force-quic-on=127.0.0.1:4433 --ignore-certificate-errors-spki-list="$SPKI" --enable-logging --v=1 ;;
1616
esac
1717

0 commit comments

Comments
 (0)