Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Implement call quality estimation (#27) #132

Merged
merged 66 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
96baa50
Add force tracks updating
evdokimovs Jul 28, 2020
828407a
Add docs
evdokimovs Jul 29, 2020
d73a57a
Fix some mute/unmute case
evdokimovs Jul 29, 2020
ec7b848
Add test [run ci]
evdokimovs Jul 29, 2020
83d8573
Refactor [run ci]
evdokimovs Jul 29, 2020
3cfb49c
Add recv Tracks muting
evdokimovs Jul 30, 2020
f8cd0fb
Merge branch 'master' into tracks-disabling-optimization
alexlapa Jul 31, 2020
b747a17
cargo update
alexlapa Jul 31, 2020
7bd125c
Add more tests [run ci]
evdokimovs Aug 3, 2020
a58f8c1
Maybe fix E2E test [run ci]
evdokimovs Aug 3, 2020
92680a8
Fix remote unmuting on new Member connecting
evdokimovs Aug 3, 2020
4461fee
Update e2e-demo
evdokimovs Aug 3, 2020
d412df7
Merge branch 'master' into senders-muting-by-subsciber
evdokimovs Aug 3, 2020
b324dc2
Reread [run ci]
evdokimovs Aug 3, 2020
c09f77e
Add CHANGELOG entry
evdokimovs Aug 3, 2020
8db6bd3
Make clippy happy [run ci]
evdokimovs Aug 3, 2020
ba4a94c
Maybe fix E2E test [run ci]
evdokimovs Aug 3, 2020
a544a2b
Debug E2E [run ci]
evdokimovs Aug 3, 2020
f444ab5
Debug [run ci]
evdokimovs Aug 4, 2020
d17d504
E2E tests should be fixed [run ci]
evdokimovs Aug 4, 2020
1fb97a9
[run ci]
evdokimovs Aug 4, 2020
a17565d
[run ci]
evdokimovs Aug 4, 2020
3fcc618
Add connection meter
evdokimovs Aug 5, 2020
cec14e7
[run ci]
evdokimovs Aug 5, 2020
acc6e40
[run ci]
evdokimovs Aug 5, 2020
cc5ef6a
Merge branch 'master' into tracks-disabling-optimization [run ci]
evdokimovs Aug 5, 2020
a4d399b
Fix formatting
evdokimovs Aug 5, 2020
913919b
Add more docs for peer module
evdokimovs Aug 6, 2020
78362d3
corrections, cargo update
alexlapa Aug 6, 2020
3cc5ac0
Add connection meter indicator
evdokimovs Aug 6, 2020
161c2cd
Delete tracks disabling changes
evdokimovs Aug 6, 2020
cd7bd56
Merge branch 'master' into poor-connection-indicator
evdokimovs Aug 6, 2020
1939351
Merge branch 'poor-connection-indicator' into poor-connection-demo
evdokimovs Aug 6, 2020
9c18ef4
Refactor
evdokimovs Aug 6, 2020
9cd00f3
add e2e test
alexlapa Aug 7, 2020
a6007ca
Fix unit tests
evdokimovs Aug 7, 2020
25f4c53
Fix text-center in chrome
evdokimovs Aug 7, 2020
82ef29d
Revert 'senders-muting-by-subsciber'
evdokimovs Aug 7, 2020
f3aa3f6
Merge branch 'tracks-disabling-optimization' into poor-connection-demo
evdokimovs Aug 7, 2020
7871666
Fix [run ci]
evdokimovs Aug 7, 2020
a481007
add todos
alexlapa Aug 7, 2020
eba32e3
Fix quality_meter
evdokimovs Aug 7, 2020
4af6d51
Fix
evdokimovs Aug 10, 2020
c583f18
Fmt
evdokimovs Aug 10, 2020
86f5d06
Remove unused code
evdokimovs Aug 10, 2020
e722095
Merge branch 'tracks-disabling-optimization' into poor-connection-demo
evdokimovs Aug 10, 2020
aef8df6
Remove some debug [run ci]
evdokimovs Aug 11, 2020
9db9666
Add docs
evdokimovs Aug 11, 2020
e31bb01
Fix quality meter on audio mute
evdokimovs Aug 12, 2020
b28b721
Add some docs
evdokimovs Aug 13, 2020
c38a920
Fix quality meter in pub-sub scenario
evdokimovs Aug 13, 2020
af352d1
Fix clippy [run ci]
evdokimovs Aug 13, 2020
eacce32
Merge branch 'master' into poor-connection-demo
alexlapa Aug 17, 2020
4f14416
merge
alexlapa Aug 17, 2020
e17ca68
refactor
alexlapa Aug 26, 2020
8931df1
Merge branch 'master' into poor-connection-demo
evdokimovs Aug 27, 2020
9179028
Merge branch 'poor-connection-demo' of github.com:instrumentisto/mede…
evdokimovs Aug 27, 2020
517bae5
Reread
evdokimovs Aug 27, 2020
d647c5c
Update RFC and CHANGELOGs [run ci]
evdokimovs Aug 27, 2020
3576cbd
Minor fixes [run ci]
evdokimovs Aug 27, 2020
07f3a39
Merge branch 'master' into poor-connection-demo
alexlapa Aug 28, 2020
5bb6426
review
alexlapa Aug 31, 2020
bebe6d3
Reread [run ci]
evdokimovs Aug 31, 2020
8970154
docs, tweak connection quality calculation [run ci]
alexlapa Aug 31, 2020
545ee77
quickfix
alexlapa Aug 31, 2020
07c08e1
Corrections
tyranron Sep 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ All user visible changes to this project will be documented in this file. This p
- Send `Event::RpcSettingsUpdated` when `Member` connects ([#75]);
- Send relay mode in `Event::PeerCreated` which is used for configuring client's `RtcIceTransportPolicy` ([#79]);
- Emit `TracksApplied` event to create new and update existing tracks ([#105]);
- `PeerConnection` renegotiation functionality ([#105]).
- `PeerConnection` renegotiation functionality ([#105]);
- Calculate and send call quality score based on RTC stats ([#132]).
- [Coturn] integration:
- [Coturn] sessions destroying ([#84]);
- [Coturn] stats processing ([#94]).
Expand Down Expand Up @@ -73,6 +74,7 @@ All user visible changes to this project will be documented in this file. This p
[#95]: /../../pull/95
[#98]: /../../pull/98
[#105]: /../../pull/105
[#132]: /../../pull/132



Expand Down
52 changes: 30 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bytes = "0.5"
chrono = "0.4"
config = "0.10"
deadpool = "0.5"
deadpool-redis = "0.6"
deadpool-redis = "=0.6.0"
derive_more = "0.99"
dotenv = "0.15"
failure = "0.1"
Expand Down
18 changes: 18 additions & 0 deletions docs/rfc/0002-webrtc-client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,24 @@ It's recommended to cache `Peer` ID and `Member` ID relations in `Web Client`'s
```
</details>

#### 10. ConnectionQualityUpdated

```rust
pub enum ConnectionQualityScore {
Poor = 1,
Low = 2,
Medium = 3,
High = 4,
}

struct ConnectionQualityUpdated {
partner_member_id: MemberId,
quality_score: ConnectionQualityScore,
}
```

`Media Server` notifies `Web Client` about connection quality score update.


### Commands

Expand Down
7 changes: 5 additions & 2 deletions jason/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ All user visible changes to this project will be documented in this file. This p
- `Room.on_connection_loss` callback that JS side can start Jason reconnection on connection loss with ([#75]);
- `Room.on_close` callback for WebSocket close initiated by server ([#55]);
- `ConnectionHandle.on_close` callback ([#120]);
- `ConnectionHandle.get_remote_member_id` method ([#124]).
- `ConnectionHandle.get_remote_member_id` method ([#124]);
- `ConnectionHandle.on_quality_score_update` callback for quality score updates received from server ([#132]).
- RPC messaging:
- Cleanup Jason state on normal (`code = 1000`) WebSocket close ([#55]);
- `RpcClient` and `RpcTransport` reconnection ([#75]).
Expand All @@ -64,7 +65,8 @@ All user visible changes to this project will be documented in this file. This p
- `ApplyTracks` for muting/unmuting ([#81]);
- `AddPeerConnectionStats` with `RtcStats` ([#90]);
- Handling of RPC events:
- `TracksApplied` ([#105]).
- `TracksApplied` ([#105]);
- `ConnectionQualityUpdated` ([#132]).
- Error handling:
- Library API:
- `JasonError` as library error with trace information and underlying JS error if it is the cause ([#55])
Expand Down Expand Up @@ -92,6 +94,7 @@ All user visible changes to this project will be documented in this file. This p
[#120]: /../../pull/120
[#123]: /../../pull/123
[#124]: /../../pull/124
[#132]: /../../pull/132



Expand Down
19 changes: 16 additions & 3 deletions jason/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@
let innerVideoDiv = document.createElement("div");
innerVideoDiv.className = "col-md-3";
innerVideoDiv.appendChild(video);
let remoteMemberIdEl = document.createElement('p');
remoteMemberIdEl.className = 'text-center';
let remoteMemberIdEl = document.createElement('span');
remoteMemberIdEl.innerHTML = remoteMemberId;
innerVideoDiv.appendChild(remoteMemberIdEl);
innerVideoDiv.appendChild(document.createElement('br'));
remote_videos[remoteMemberId] = innerVideoDiv;
videoDiv.appendChild(innerVideoDiv);

Expand Down Expand Up @@ -533,6 +533,19 @@
remote_videos[remoteMemberId].remove();
delete remote_videos[remoteMemberId];
});

connection.on_quality_score_update((score) => {
let videoDiv = remote_videos[remoteMemberId];
let el = videoDiv.getElementsByClassName('quality-score');

if (el[0] === undefined) {
let qualityEl = document.createElement('span');
qualityEl.innerHTML = score;
qualityEl.className = 'quality-score';
videoDiv.appendChild(qualityEl);
}
el[0].innerHTML = score;
})
});

room.on_local_stream((stream) => {
Expand Down Expand Up @@ -691,7 +704,7 @@
</div>

<div id="video-call" style="display: none">
<div id="remote-videos" class="row">
<div id="remote-videos" class="row text-center">
</div>

<div class="row h-25 w-75">
Expand Down
13 changes: 13 additions & 0 deletions jason/e2e-demo/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,19 @@ window.onload = async function() {
remote_videos[remoteMemberId].remove();
delete remote_videos[remoteMemberId];
});

connection.on_quality_score_update((score) => {
let videoDiv = remote_videos[remoteMemberId];
let el = videoDiv.getElementsByClassName('quality-score');

if (el[0] === undefined) {
let qualityEl = document.createElement('span');
qualityEl.innerHTML = score;
qualityEl.className = 'quality-score';
videoDiv.appendChild(qualityEl);
}
el[0].innerHTML = score;
})
});

room.on_local_stream((stream) => {
Expand Down
1 change: 1 addition & 0 deletions jason/e2e-demo/video-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
.remote-videos {
display: flex;
width: 100%;
margin-top: 30px;
justify-content: space-around;
}

Expand Down
34 changes: 31 additions & 3 deletions jason/src/api/connection.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Connection with specific remote `Member`.

use std::{
cell::RefCell,
cell::{Cell, RefCell},
collections::{HashMap, HashSet},
rc::{Rc, Weak},
};

use medea_client_api_proto::{MemberId, PeerId, TrackId};
use medea_client_api_proto::{
ConnectionQualityScore, MemberId, PeerId, TrackId,
};
use wasm_bindgen::prelude::*;

use crate::{
Expand Down Expand Up @@ -102,10 +104,17 @@ struct InnerConnection {
/// [`PeerMediaStream`] received from remote member.
remote_stream: RefCell<Option<PeerMediaStream>>,

/// Current [`ConnectionQualityScore`] of this [`Connection`].
quality_score: Cell<Option<ConnectionQualityScore>>,

/// JS callback, that will be invoked when remote [`PeerMediaStream`] is
/// received.
on_remote_stream: Callback1<RemoteMediaStream>,

/// JS callback, that will be invoked when [`ConnectionQualityScore`] will
/// be updated.
on_quality_score_update: Callback1<u8>,

/// JS callback, that will be invoked when this connection is closed.
on_close: Callback0,
}
Expand All @@ -132,6 +141,16 @@ impl ConnectionHandle {
pub fn get_remote_member_id(&self) -> Result<String, JsValue> {
upgrade_or_detached!(self.0).map(|inner| inner.remote_id.0.clone())
}

/// Sets callback, which will be invoked when connection quality score will
/// be updated by server.
pub fn on_quality_score_update(
&self,
f: js_sys::Function,
) -> Result<(), JsValue> {
upgrade_or_detached!(self.0)
.map(|inner| inner.on_quality_score_update.set_func(f))
}
}

/// Connection with a specific remote [`Member`], that is used on Rust side.
Expand All @@ -146,8 +165,10 @@ impl Connection {
pub fn new(remote_id: MemberId) -> Self {
Self(Rc::new(InnerConnection {
remote_id,
remote_stream: RefCell::new(None),
remote_stream: RefCell::default(),
quality_score: Cell::default(),
on_remote_stream: Callback1::default(),
on_quality_score_update: Callback1::default(),
on_close: Callback0::default(),
}))
}
Expand All @@ -173,4 +194,11 @@ impl Connection {
pub fn new_handle(&self) -> ConnectionHandle {
ConnectionHandle(Rc::downgrade(&self.0))
}

/// Updates [`ConnectionQualityScore`] of this [`Connection`].
pub fn update_quality_score(&self, score: ConnectionQualityScore) {
if self.0.quality_score.replace(Some(score)) != Some(score) {
self.0.on_quality_score_update.call(score as u8);
}
}
}
Loading