This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 819
Add ability to change audio and video devices during a call #7173
Merged
SimonBrandner
merged 16 commits into
matrix-org:develop
from
SimonBrandner:feature/mid-call-device-change
May 4, 2022
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6778c06
Add `getDevice()`
SimonBrandner 904e31d
Add `onHover()`
SimonBrandner f8d0bf0
Give call view buttons a box-shadow
SimonBrandner 1724c96
Add styling for DeviceContextMenu
SimonBrandner 750cdb6
Add IconizedContextMenuOptionList label
SimonBrandner 80d3f2f
Add DeviceContextMenu
SimonBrandner e7dcef9
Add CallViewDropdownButton styling
SimonBrandner c998095
Add CallViewDropdownButton
SimonBrandner db1d01e
i18n
SimonBrandner dc9192c
Add a defautl for WebRTC device settings
SimonBrandner 364db46
Make `setDevice()` methods async
SimonBrandner ed97738
`playMedia()` in `onNewStream()`
SimonBrandner 71e648e
Merge remote-tracking branch 'upstream/develop' into feature/mid-call…
SimonBrandner 0f53fb7
Merge remote-tracking branch 'upstream/develop' into feature/mid-call…
SimonBrandner 8539333
Merge branch 'develop' into feature/mid-call-device-change
SimonBrandner eaa2923
Merge remote-tracking branch 'upstream/develop' into feature/mid-call…
SimonBrandner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright 2021 Šimon Brandner <[email protected]> | ||
|
||
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. | ||
*/ | ||
|
||
.mx_DeviceContextMenu { | ||
max-width: 252px; | ||
|
||
.mx_DeviceContextMenu_device_icon { | ||
display: none; | ||
} | ||
|
||
.mx_IconizedContextMenu_label { | ||
padding-left: 0 !important; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright 2021 Šimon Brandner <[email protected]> | ||
|
||
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 React, { useEffect, useState } from "react"; | ||
|
||
import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../../MediaDeviceHandler"; | ||
import IconizedContextMenu, { IconizedContextMenuOptionList, IconizedContextMenuRadio } from "./IconizedContextMenu"; | ||
import { IProps as IContextMenuProps } from "../../structures/ContextMenu"; | ||
import { _t, _td } from "../../../languageHandler"; | ||
|
||
const SECTION_NAMES: Record<MediaDeviceKindEnum, string> = { | ||
[MediaDeviceKindEnum.AudioInput]: _td("Input devices"), | ||
[MediaDeviceKindEnum.AudioOutput]: _td("Output devices"), | ||
[MediaDeviceKindEnum.VideoInput]: _td("Cameras"), | ||
}; | ||
|
||
interface IDeviceContextMenuDeviceProps { | ||
label: string; | ||
selected: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
const DeviceContextMenuDevice: React.FC<IDeviceContextMenuDeviceProps> = ({ label, selected, onClick }) => { | ||
return <IconizedContextMenuRadio | ||
iconClassName="mx_DeviceContextMenu_device_icon" | ||
label={label} | ||
active={selected} | ||
onClick={onClick} | ||
/>; | ||
}; | ||
|
||
interface IDeviceContextMenuSectionProps { | ||
deviceKind: MediaDeviceKindEnum; | ||
} | ||
|
||
const DeviceContextMenuSection: React.FC<IDeviceContextMenuSectionProps> = ({ deviceKind }) => { | ||
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]); | ||
const [selectedDevice, setSelectedDevice] = useState(MediaDeviceHandler.getDevice(deviceKind)); | ||
|
||
useEffect(() => { | ||
const getDevices = async () => { | ||
return setDevices((await MediaDeviceHandler.getDevices())[deviceKind]); | ||
}; | ||
getDevices(); | ||
}, [deviceKind]); | ||
|
||
const onDeviceClick = (deviceId: string): void => { | ||
MediaDeviceHandler.instance.setDevice(deviceId, deviceKind); | ||
setSelectedDevice(deviceId); | ||
}; | ||
|
||
return <IconizedContextMenuOptionList label={_t(SECTION_NAMES[deviceKind])}> | ||
{ devices.map(({ label, deviceId }) => { | ||
return <DeviceContextMenuDevice | ||
key={deviceId} | ||
label={label} | ||
selected={selectedDevice === deviceId} | ||
onClick={() => onDeviceClick(deviceId)} | ||
/>; | ||
}) } | ||
</IconizedContextMenuOptionList>; | ||
}; | ||
|
||
interface IProps extends IContextMenuProps { | ||
deviceKinds: MediaDeviceKind[]; | ||
} | ||
|
||
const DeviceContextMenu: React.FC<IProps> = ({ deviceKinds, ...props }) => { | ||
return <IconizedContextMenu compact className="mx_DeviceContextMenu" {...props}> | ||
{ deviceKinds.map((kind) => { | ||
return <DeviceContextMenuSection key={kind} deviceKind={kind as MediaDeviceKindEnum} />; | ||
}) } | ||
</IconizedContextMenu>; | ||
}; | ||
|
||
export default DeviceContextMenu; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.