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

Implement media muting/unmuting (#27) #156

Merged
merged 48 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
9783fc6
Rename [run ci]
evdokimovs Oct 30, 2020
bfebf11
[run ci]
evdokimovs Oct 30, 2020
f8ba4a7
Abstract
evdokimovs Nov 2, 2020
588ab21
Abstract
evdokimovs Nov 2, 2020
7f988a9
Stage 1
evdokimovs Nov 2, 2020
ef9638b
Impl
evdokimovs Nov 3, 2020
58bbf9a
Refactor
evdokimovs Nov 3, 2020
dfa6280
Impl deep cloning for MediaStreamTrack
evdokimovs Nov 4, 2020
296dcbe
Decrease duplication
evdokimovs Nov 4, 2020
a8e5fa6
Cleanup
evdokimovs Nov 4, 2020
77ecba6
Implement muting before call
evdokimovs Nov 4, 2020
fddcf1b
Refactor
evdokimovs Nov 4, 2020
b514d94
Add docs, refactor, cleanup
evdokimovs Nov 5, 2020
7e2b39c
Fix tests
evdokimovs Nov 5, 2020
71490c5
Reread
evdokimovs Nov 5, 2020
f5878c3
Add tests
evdokimovs Nov 5, 2020
ae1d39d
Don't renegotiate on mute/unmute
evdokimovs Nov 5, 2020
7b274cc
Extend tests
evdokimovs Nov 5, 2020
3d00612
Add muting to the Jason demo
evdokimovs Nov 5, 2020
864a7b1
Impl receiver side muting/unmuting
evdokimovs Nov 5, 2020
31f7f53
Reread [run ci]
evdokimovs Nov 5, 2020
df3d757
Upd CHANGELOGs
evdokimovs Nov 5, 2020
5998a7e
Minor fix [run ci]
evdokimovs Nov 5, 2020
80a037e
Merge branch 'rename-mute-to-disable' into implement-muting
evdokimovs Nov 5, 2020
7db1144
Upd CHANGELOG
evdokimovs Nov 5, 2020
29f864c
Merge branch 'master' into implement-muting
evdokimovs Nov 11, 2020
d2cdb73
[run ci]
evdokimovs Nov 11, 2020
6bc483d
Move more 'mockable' feature functions to the modules
evdokimovs Nov 12, 2020
b6dfaa7
Merge branch 'master' into implement-muting
evdokimovs Nov 13, 2020
38c659b
Reread
evdokimovs Nov 16, 2020
e422ca9
Fix transition timers stopping
evdokimovs Nov 17, 2020
33ad9c1
Add tests [run ci]
evdokimovs Nov 17, 2020
1cc9ac2
Refactor MediaStreamTrack deep cloning logic
evdokimovs Nov 18, 2020
58ebb5c
refactor
alexlapa Nov 18, 2020
adf4c15
refactor
alexlapa Nov 19, 2020
33bd1a2
refactor
alexlapa Nov 19, 2020
29fe375
Add docs
evdokimovs Nov 19, 2020
c44fca2
Upgrade chromedriver to 87.0
evdokimovs Nov 19, 2020
262efa9
Fix outdated docs
evdokimovs Nov 19, 2020
f4685ba
Remove state machine from the local::Track and use Rc/Weak
evdokimovs Nov 19, 2020
cdaba5b
Fix tests
evdokimovs Nov 19, 2020
c880539
Upd CHANGELOG
evdokimovs Nov 19, 2020
03e3079
refactor [run ci]
alexlapa Nov 20, 2020
cadf2c8
Merge branch 'master' into implement-muting
evdokimovs Nov 25, 2020
bf00c19
Fix private intra-doc [run ci]
evdokimovs Nov 25, 2020
2f6263e
refactor [run ci]
alexlapa Nov 25, 2020
95bc1cb
refactor
alexlapa Nov 25, 2020
b259d3e
Corrections
tyranron Nov 26, 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 @@ -42,7 +42,8 @@ All user visible changes to this project will be documented in this file. This p
- Calculate and send call quality score based on RTC stats ([#132]);
- Enabling/disabling `MediaTrack`s by receiver ([#127], [#155]);
- Send `TrackUpdate::IceRestart` based on RTC stats analysis ([#138]);
- Multiple `Room`s served by one RPC connection support ([#147]).
- Multiple `Room`s served by one RPC connection support ([#147]);
- Muting/unmuting `MediaTrack`s ([#156]).
- [Coturn] integration:
- [Coturn] sessions destroying ([#84]);
- [Coturn] stats processing ([#94]).
Expand Down Expand Up @@ -85,6 +86,7 @@ All user visible changes to this project will be documented in this file. This p
[#147]: /../../pull/147
[#153]: /../../pull/153
[#155]: /../../pull/155
[#156]: /../../pull/156



Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ DEMO_IMAGE_NAME := instrumentisto/medea-demo
CONTROL_MOCK_IMAGE_NAME := instrumentisto/medea-control-api-mock

RUST_VER := 1.48
CHROME_VERSION := 86.0
FIREFOX_VERSION := 82.0.2
CHROME_VERSION := 87.0
FIREFOX_VERSION := 83.0

crate-dir = .
ifeq ($(crate),medea-jason)
Expand Down
21 changes: 15 additions & 6 deletions jason/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,30 @@ All user visible changes to this project will be documented in this file. This p
- `DeviceVideoTrackConstraints`, `DisplayVideoTrackConstraints` classes ([#78]);
- `DeviceVideoTrackConstraints.ideal_facing_mode` and `DeviceVideoTrackConstraints.exact_facing_mode` functions ([#137]);
- `FacingMode` enum ([#137]).
- `MediaKind` enum that provides `MediaTrack` and `InputDeviceInfo` kind ([#146]);
- `MediaSourceKind` enum that provides `MediaTrack` media source kind (`Device` or `Display`) ([#146]);
- `MediaKind` enum that provides `LocalMediaTrack`/`RemoteMediaTrack` and `InputDeviceInfo` kind ([#146]);
- `MediaSourceKind` enum that provides `MediaTrack` media source kind (`Device` or `Display`) ([#146], [#156]);
- Room management:
- `Jason.init_room()` ([#46]);
- `Room.join()` ([#46]);
- `Jason.close_room()` ([#147]).
- Ability to configure local media stream used by `Room` via `Room.set_local_media_settings()` ([#54], [#97], [#145]);
- `Room.on_failed_local_media` callback ([#54], [#143]);
- `Room.on_close` callback for WebSocket close initiated by server ([#55]);
- `MediaTrack.on_enabled` and `MediaTrack.on_disabled` callbacks being called when `MediaTrack` is enabled or disabled ([#123], [#143]);
- `ConnectionHandle.on_remote_track_added` callback being called when new receiver `MediaTrack` is added ([#123], [#143]);
- `RemoteMediaTrack.on_enabled` and `RemoteMediaTrack.on_disabled` callbacks being called when `RemoteMediaTrack` is enabled or disabled ([#123], [#143], [#156]);
- `ConnectionHandle.on_remote_track_added` callback being called when new receiver `RemoteMediaTrack` is added ([#123], [#143], [#156]);
- Enabling/disabling remote video/audio ([#127], [#155]):
- `Room.disable_remote_audio`;
- `Room.enable_remote_audio`;
- `Room.disable_remote_video`;
- `Room.enable_remote_video`.
- `MediaTrack.media_source_kind` function ([#145], [#146]).
- Muting/unmuting audio/video send ([#156]):
- `Room.mute_audio`;
- `Room.unmute_audio`;
- `Room.mute_video`;
- `Room.unmute_video`.
- `RemoteMediaTrack`/`LocalMediaTrack` `media_source_kind` function ([#145], [#146], [#156]);
- `RemoteMediaTrack` class ([#156]);
- `LocalMediaTrack` class ([#156]).
- Optional tracks support ([#106]);
- Simultaneous device and display video tracks publishing and receiving ([#144]);
- `RtcIceTransportPolicy` configuration ([#79]).
Expand All @@ -73,8 +80,9 @@ All user visible changes to this project will be documented in this file. This p
- Signalling:
- Emitting of RPC commands:
- `AddPeerConnectionMetrics` with `IceConnectionState` and `PeerConnectionState` ([#71], [#87]);
- `ApplyTracks` for enabling/disabling ([#81], [#155]);
- `AddPeerConnectionStats` with `RtcStats` ([#90]);
- Enabling/disabling audio/video send/receive via `UpdateTracks` command ([#81], [#155]);
- Muting/unmuting audio/video send via `UpdateTracks` ([#156]).
- Handling of RPC events:
- `TracksApplied` with `TrackUpdate::Added`, `TrackUpdate::Updated` and `TrackUpdate::IceRestart` ([#105], [#138]);
- `ConnectionQualityUpdated` ([#132]).
Expand Down Expand Up @@ -115,6 +123,7 @@ All user visible changes to this project will be documented in this file. This p
[#146]: /../../pull/146
[#147]: /../../pull/147
[#155]: /../../pull/155
[#156]: /../../pull/156



Expand Down
38 changes: 38 additions & 0 deletions jason/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
let disableVideoSendBtn = document.getElementById('control__disable_video_send');
let disableAudioRecvBtn = document.getElementById('control__disable_audio_recv');
let disableVideoRecvBtn = document.getElementById('control__disable_video_recv');
let muteAudioSendBtn = document.getElementById('control__mute_audio_send');
let muteVideoSendBtn = document.getElementById('control__mute_video_send');
let joinCallerButton = document.getElementById('join__join');
let connectionState = document.getElementById('connection-state__state');
let videoDiv = document.getElementById('remote-videos');
Expand All @@ -60,6 +62,8 @@
let isVideoSendEnabled = true;
let isAudioRecvEnabled = true;
let isVideoRecvEnabled = true;
let isAudioMuted = false;
let isVideoMuted = false;
let isPublishingEnabled = true;
let remote_videos = [];

Expand Down Expand Up @@ -718,6 +722,36 @@
disableVideoRecvBtn.textContent = 'Disable video recv';
}
});
muteAudioSendBtn.addEventListener('click', async () => {
try {
if (isAudioMuted) {
await room.unmute_audio();
isAudioMuted = false;
muteAudioSendBtn.textContent = 'Mute audio send';
} else {
await room.mute_audio();
isAudioMuted = true;
muteAudioSendBtn.textContent = 'Unmute audio send';
}
} catch (e) {
console.error(e.trace());
}
});
muteVideoSendBtn.addEventListener('click', async () => {
try {
if (isVideoMuted) {
await room.unmute_video();
isVideoMuted = false;
muteVideoSendBtn.textContent = 'Mute video send';
} else {
await room.mute_video();
isVideoMuted = true;
muteVideoSendBtn.textContent = 'Unmute video send';
}
} catch (e) {
console.error(e.trace());
}
});

let roomId = window.location.hash.replace('#', '');

Expand Down Expand Up @@ -854,6 +888,10 @@
<button class="btn btn-info" id="control__disable_audio_recv">Disable audio recv</button>
<button class="btn btn-info" id="control__disable_video_recv">Disable video recv</button>
</div>
<div>
<button class="btn btn-info" id="control__mute_audio_send">Mute audio send</button>
<button class="btn btn-info" id="control__mute_video_send">Mute video send</button>
</div>
</div>

<div class="mb-3">
Expand Down
34 changes: 34 additions & 0 deletions jason/e2e-demo/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let disableAudioSend = document.getElementById('control__disable_audio_send');
let disableVideoSend = document.getElementById('control__disable_video_send');
let disableAudioRecv = document.getElementById('control__disable_audio_recv');
let disableVideoRecv = document.getElementById('control__disable_video_recv');
let muteAudioSend = document.getElementById('control__mute_audio_send');
let muteVideoSend = document.getElementById('control__mute_video_send');
let closeApp = document.getElementById('control__close_app');
let audioSelect = document.getElementById('connect__select-device_audio');
let videoSelect = document.getElementById('connect__select-device_video');
Expand Down Expand Up @@ -453,6 +455,8 @@ window.onload = async function() {
let isVideoSendEnabled = true;
let isAudioRecvEnabled = true;
let isVideoRecvEnabled = true;
let isAudioMuted = false;
let isVideoMuted = false;
let room = await newRoom();

async function initLocalStream() {
Expand Down Expand Up @@ -818,6 +822,36 @@ window.onload = async function() {
console.error(e.trace());
}
});
muteAudioSend.addEventListener('click', async () => {
try {
if (isAudioMuted) {
await room.unmute_audio();
isAudioMuted = false;
muteAudioSend.textContent = 'Mute audio send';
} else {
await room.mute_audio();
isAudioMuted = true;
muteAudioSend.textContent = 'Unmute audio send';
}
} catch (e) {
console.error(e.trace());
}
});
muteVideoSend.addEventListener('click', async () => {
try {
if (isVideoMuted) {
await room.unmute_video();
isVideoMuted = false;
muteVideoSend.textContent = 'Mute video send';
} else {
await room.mute_video();
isVideoMuted = true;
muteVideoSend.textContent = 'Unmute video send';
}
} catch (e) {
console.error(e.trace());
}
});
disableAudioRecv.addEventListener('click', async () => {
if (isAudioRecvEnabled) {
await room.disable_remote_audio();
Expand Down
4 changes: 4 additions & 0 deletions jason/e2e-demo/video-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
<button id="control__disable_audio_recv" class="btn btn-secondary">Disable audio recv</button>
<button id="control__disable_video_recv" class="btn btn-secondary">Disable video recv</button>
</div>
<div class="mb-3">
<button id="control__mute_audio_send" class="btn btn-secondary">Mute audio send</button>
<button id="control__mute_video_send" class="btn btn-secondary">Mute video send</button>
</div>
<button type="button"
class="btn btn-secondary"
data-toggle="modal"
Expand Down
14 changes: 7 additions & 7 deletions jason/src/api/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use medea_client_api_proto::{ConnectionQualityScore, MemberId, PeerId};
use wasm_bindgen::prelude::*;

use crate::{
media::MediaStreamTrack,
media::track::remote,
utils::{Callback0, Callback1, HandlerDetachedError},
};

Expand Down Expand Up @@ -101,9 +101,9 @@ struct InnerConnection {
/// Current [`ConnectionQualityScore`] of this [`Connection`].
quality_score: Cell<Option<ConnectionQualityScore>>,

/// JS callback, that will be invoked when remote [`MediaStreamTrack`] is
/// JS callback, that will be invoked when [`remote::Track`] is
/// received.
on_remote_track_added: Callback1<MediaStreamTrack>,
on_remote_track_added: Callback1<remote::Track>,

/// JS callback, that will be invoked when [`ConnectionQualityScore`] will
/// be updated.
Expand All @@ -125,8 +125,8 @@ impl ConnectionHandle {
upgrade_or_detached!(self.0).map(|inner| inner.remote_id.0.clone())
}

/// Sets callback, which will be invoked when new remote
/// [`MediaStreamTrack`] will be added to this [`Connection`].
/// Sets callback, which will be invoked when new [`remote::Track`] will be
/// added to this [`Connection`].
pub fn on_remote_track_added(
&self,
f: js_sys::Function,
Expand Down Expand Up @@ -164,8 +164,8 @@ impl Connection {
}

/// Invokes `on_remote_track_added` JS callback with the provided
/// [`MediaStreamTrack`].
pub fn add_remote_track(&self, track: MediaStreamTrack) {
/// [`remote::Track`].
pub fn add_remote_track(&self, track: remote::Track) {
self.0.on_remote_track_added.call(track);
}

Expand Down
Loading