Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Push-to-Talk Support for Jitsi #2280

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8481a7b
Jitsi Push-to-Talk
anoadragon453 Nov 15, 2018
1a2923b
lint
anoadragon453 Nov 15, 2018
f5fbf97
Fix settings look
anoadragon453 Nov 21, 2018
4a0a26a
Add support for custom keybinding names
anoadragon453 Feb 12, 2019
aaa8aaa
Update rimraf
anoadragon453 Feb 12, 2019
dc0a6af
Remove UserSettings.js
anoadragon453 Feb 21, 2019
177d73c
Remove small fixes, electron addage
anoadragon453 Feb 21, 2019
964e850
hey it all works
anoadragon453 Feb 21, 2019
67a0cd5
Getting there
anoadragon453 Feb 22, 2019
22663c1
Fix issues
anoadragon453 Feb 22, 2019
2a41ebc
Add PTT toggle mode
anoadragon453 Feb 23, 2019
75b7fd0
UI Fixes
anoadragon453 Feb 24, 2019
6050c95
Cleanup, and ability to change shortcut during call
anoadragon453 Feb 24, 2019
d346c13
Update comments
anoadragon453 Feb 24, 2019
2e739cf
lint
anoadragon453 Feb 24, 2019
52348f7
lint
anoadragon453 Feb 24, 2019
6ac47fb
Fix UI and being unable to talk to widget
anoadragon453 Feb 27, 2019
fc7b1b3
Merge branch 'develop' into anoa/jitsi_ptt
anoadragon453 Feb 27, 2019
7e8411d
Fix build issues, move PushToTalk to class
anoadragon453 Feb 28, 2019
5cca1b4
Prevent erroneously setting state outside of settings window
anoadragon453 Mar 7, 2019
891554c
Change copyright and comment
anoadragon453 Mar 8, 2019
af78fa1
Fix custom key translations
anoadragon453 Mar 8, 2019
355d490
Remove dead code and fix translation
anoadragon453 Mar 8, 2019
ecf6596
Add translation to 'Not set'
anoadragon453 Mar 8, 2019
7d0fbc8
Merge branch 'develop' into anoa/jitsi_ptt
anoadragon453 Mar 20, 2019
1d10373
Change to yarn
anoadragon453 Mar 20, 2019
9dabafd
Merge branch 'develop' into anoa/jitsi_ptt
anoadragon453 Apr 8, 2019
3d11535
Merge branch 'develop' into anoa/jitsi_ptt
anoadragon453 Jul 12, 2019
ea20e60
Bump widget post message api version
anoadragon453 Jul 19, 2019
71fb229
Merge branch 'develop' into anoa/jitsi_ptt
anoadragon453 Aug 3, 2019
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"mocha": "^5.0.5",
"react-addons-test-utils": "^15.4.0",
"require-json": "0.0.1",
"rimraf": "^2.4.3",
"rimraf": "^2.6.2",
"sinon": "^5.0.7",
"source-map-loader": "^0.2.3",
"stylelint": "^9.10.1",
Expand Down
14 changes: 14 additions & 0 deletions res/css/views/settings/tabs/user/_VoiceUserSettingsTab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ limitations under the License.
margin-right: 100px; // align with the rest of the fields
}

.mx_Shortcut {
height: 30px;
}

.mx_Shortcut_label {
margin-left: 30px;
}

.mx_VoiceUserSettingsTab .mx_ShortcutSet {
float: right;
width: 48px;
margin-right: 17px;
}

.mx_VoiceUserSettingsTab_missingMediaPermissions {
margin-bottom: 15px;
}
3 changes: 2 additions & 1 deletion src/FromWidgetPostMessageApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import MatrixClientPeg from "./MatrixClientPeg";
import RoomViewStore from "./stores/RoomViewStore";
import { showIntegrationsManager } from './integrations/integrations';

const WIDGET_API_VERSION = '0.0.2'; // Current API version
const WIDGET_API_VERSION = '0.0.3'; // Current API version
const SUPPORTED_WIDGET_API_VERSIONS = [
'0.0.1',
'0.0.2',
'0.0.3',
];
const INBOUND_API_NAME = 'fromWidget';

Expand Down
83 changes: 83 additions & 0 deletions src/PushToTalk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Copyright 2019 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import PlatformPeg from './PlatformPeg';
import ActiveWidgetStore from './stores/ActiveWidgetStore';
import SettingsStore, { SettingLevel } from './settings/SettingsStore';

export default class PushToTalk {
static id = "pushToTalk";

static start(keybinding) {
// Call starting, start listening for keys
const currentPTTState = SettingsStore.getValue(this.id);
currentPTTState.isInCall = true;
SettingsStore.setValue(this.id, null, SettingLevel.DEVICE, currentPTTState);
this.setKeybinding(keybinding);
}

static stop() {
// Call finished, stop listening for keys
const currentPTTState = SettingsStore.getValue(this.id);
currentPTTState.isInCall = false;
SettingsStore.setValue(this.id, null, SettingLevel.DEVICE, currentPTTState);
this.removeKeybinding();
}

static setKeybinding(keybinding) {
// Add keybinding listener
PlatformPeg.get().addGlobalKeybinding(this.id, keybinding, () => {
const widgetId = ActiveWidgetStore.getPersistentWidgetId();

// Only try to un/mute if jitsi is onscreen
if (widgetId === null || widgetId === undefined) {
return;
}

const widgetMessaging = ActiveWidgetStore.getWidgetMessaging(widgetId);

// Toggle mic if in toggle mode, else just activate mic
if (SettingsStore.getValue(this.id).toggle) {
widgetMessaging.toggleJitsiAudio();
} else {
widgetMessaging.unmuteJitsiAudio();
}
}, () => {
// No release functionality if toggle mode is enabled
if (SettingsStore.getValue(this.id).toggle === true) {
return;
}

const widgetId = ActiveWidgetStore.getPersistentWidgetId();

// Only try to un/mute if jitsi is onscreen
if (widgetId === null || widgetId === undefined) {
return;
}

const widgetMessaging = ActiveWidgetStore.getWidgetMessaging(widgetId);
widgetMessaging.muteJitsiAudio();
});
PlatformPeg.get().startListeningKeys();
}

static removeKeybinding() {
// Remove keybinding listener
const keybinding = SettingsStore.getValue(this.id).keybinding;
PlatformPeg.get().removeGlobalKeybinding(this.id, keybinding);
PlatformPeg.get().stopListeningKeys();
}
}
39 changes: 39 additions & 0 deletions src/WidgetMessaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,45 @@ export default class WidgetMessaging {
});
}

/**
* Toggle Jitsi Audio Mute
* @return {Promise} To be resolved when action completed
*/
toggleJitsiAudio() {
return this.messageToWidget({
api: OUTBOUND_API_NAME,
action: "audioToggle",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 3 actions should require a bump in API version, as shown here: https://github.com/matrix-org/matrix-react-sdk/pull/2781/files#diff-48acd843c021678a317564b0cf6d8648R24

Also, if you need to figure out if the widget will even support it, a toWidget API request for supported_api_versions should reveal that.

Copy link
Member Author

@anoadragon453 anoadragon453 Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So doing this instead of checking for "jitsi" may be better?

We don't check this way anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending to an older version is alright though, as it will just ignore the command?

}).then((response) => {
return response.success;
});
}

/**
* Jitsi Audio Mute
* @return {Promise} To be resolved when action completed
*/
muteJitsiAudio() {
return this.messageToWidget({
api: OUTBOUND_API_NAME,
action: "audioMute",
}).then((response) => {
return response.success;
});
}

/**
* Jitsi Audio Unmute
* @return {Promise} To be resolved when action completed
*/
unmuteJitsiAudio() {
return this.messageToWidget({
api: OUTBOUND_API_NAME,
action: "audioUnmute",
}).then((response) => {
return response.success;
});
}

sendVisibility(visible) {
return this.messageToWidget({
api: OUTBOUND_API_NAME,
Expand Down
14 changes: 13 additions & 1 deletion src/components/views/elements/PersistedElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ limitations under the License.
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';

import ResizeObserver from 'resize-observer-polyfill';
import SettingsStore from '../../../settings/SettingsStore';

import PushToTalk from '../../../PushToTalk';

import dis from '../../../dispatcher';

Expand Down Expand Up @@ -112,6 +114,11 @@ export default class PersistedElement extends React.Component {
}

componentDidMount() {
// Start Push-To-Talk service when Jitsi widget is mounted
if (this.props.persistKey.includes('jitsi') && SettingsStore.getValue(PushToTalk.id).enabled) {
PushToTalk.start(SettingsStore.getValue(PushToTalk.id).keybinding);
}

this.updateChild();
}

Expand All @@ -124,6 +131,11 @@ export default class PersistedElement extends React.Component {
this.resizeObserver.disconnect();
window.removeEventListener('resize', this._repositionChild);
dis.unregister(this._dispatcherRef);

// Stop Push-To-Talk service when Jitsi widget is unmounted
if (this.props.persistKey.includes('jitsi') && SettingsStore.getValue(PushToTalk.id).enabled) {
PushToTalk.stop();
}
}

_onAction(payload) {
Expand Down
Loading