mirror of https://github.com/vector-im/riot-web
Get screen-sharing working, somehow
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>pull/21833/head
parent
777c0ca1ef
commit
eae3c1c496
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||
|
||||
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_streamSelectorDialog {
|
||||
-ms-text-overflow: ellipsis;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
padding-right: 80px;
|
||||
}
|
||||
.desktop-capturer-selection-scroller {
|
||||
width: 100%;
|
||||
max-height: 100vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.desktop-capturer-selection-list {
|
||||
max-width: calc(100% - 100px);
|
||||
margin: 0 50px 0 50px;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
list-style: none;
|
||||
overflow: hidden;
|
||||
justify-content: center;
|
||||
}
|
||||
.desktop-capturer-selection-item {
|
||||
display: flex;
|
||||
margin: 4px;
|
||||
}
|
||||
.desktop-capturer-selection-button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 145px;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
background: #20262b;
|
||||
color: #ffffff;
|
||||
text-align: left;
|
||||
transition: background-color .15s, box-shadow .15s;
|
||||
}
|
||||
.desktop-capturer-selection-button:hover,
|
||||
.desktop-capturer-selection-button:focus {
|
||||
background: #363c43;
|
||||
}
|
||||
.desktop-capturer-selection-thumbnail {
|
||||
width: 100%;
|
||||
height: 81px;
|
||||
object-fit: cover;
|
||||
}
|
||||
.desktop-capturer-selection-name {
|
||||
margin: 6px 0 6px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
|
@ -82,6 +82,13 @@ import CountlyAnalytics from "./CountlyAnalytics";
|
|||
import {UIFeature} from "./settings/UIFeature";
|
||||
import { CallError } from "matrix-js-sdk/src/webrtc/call";
|
||||
import { logger } from 'matrix-js-sdk/src/logger';
|
||||
import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapturerSourcePicker"
|
||||
|
||||
export interface ElectronDesktopCapturerSource {
|
||||
display_id: string;
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
enum AudioID {
|
||||
Ring = 'ringAudio',
|
||||
|
@ -474,7 +481,23 @@ export default class CallHandler {
|
|||
});
|
||||
return;
|
||||
}
|
||||
call.placeScreenSharingCall(remoteElement, localElement);
|
||||
|
||||
const selectDesktopCapturerSource = async (
|
||||
sources: Array<ElectronDesktopCapturerSource>,
|
||||
): Promise<ElectronDesktopCapturerSource> => {
|
||||
console.log(DesktopCapturerSourcePicker);
|
||||
const params = {
|
||||
sources: sources,
|
||||
};
|
||||
|
||||
const {finished} = Modal.createDialog(DesktopCapturerSourcePicker, params);
|
||||
|
||||
const [source] = await finished;
|
||||
console.log("Dialog closed with", source);
|
||||
return source;
|
||||
};
|
||||
|
||||
call.placeScreenSharingCall(remoteElement, localElement, selectDesktopCapturerSource);
|
||||
} else {
|
||||
console.error("Unknown conf call type: %s", type);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||
|
||||
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 from 'react';
|
||||
import { _td } from '../../../languageHandler';
|
||||
import BaseDialog from "..//dialogs/BaseDialog"
|
||||
|
||||
export interface DesktopCapturerSourceIProps {
|
||||
source: ElectronDesktopCapturerSource,
|
||||
onSelect(source: ElectronDesktopCapturerSource): void,
|
||||
}
|
||||
|
||||
export class DesktopCapturerSource extends React.Component<DesktopCapturerSourceIProps> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
onClick = (ev) => {
|
||||
//ev.stopPropagation();
|
||||
this.props.onSelect(this.props.source);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<button
|
||||
className="desktop-capturer-selection-button"
|
||||
data-id={this.props.source.id}
|
||||
title={this.props.source.name}
|
||||
onClick={this.onClick} >
|
||||
<img
|
||||
className="desktop-capturer-selection-thumbnail"
|
||||
src={this.props.source.thumbnail.toDataURL()}
|
||||
/>
|
||||
<span className="desktop-capturer-selection-name">{this.props.source.name}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ElectronDesktopCapturerSource {
|
||||
display_id: string;
|
||||
id: string;
|
||||
name: string;
|
||||
thumbnail,
|
||||
appIcon,
|
||||
}
|
||||
|
||||
|
||||
export interface DesktopCapturerSourcePickerIProps {
|
||||
sources: Array<ElectronDesktopCapturerSource>;
|
||||
onFinished(source: ElectronDesktopCapturerSource): void,
|
||||
}
|
||||
|
||||
// TODO: Figure out a way to update sources for live preview
|
||||
|
||||
export default class DesktopCapturerSourcePicker extends React.Component<DesktopCapturerSourcePickerIProps> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
onSelect = (source) => {
|
||||
this.props.onFinished(source);
|
||||
}
|
||||
|
||||
render() {
|
||||
const screens = this.props.sources
|
||||
.filter((source) => {
|
||||
return source.id.startsWith("screen");
|
||||
})
|
||||
.map((source) => {
|
||||
return <DesktopCapturerSource source={source} onSelect={this.onSelect} key={source.id} />;
|
||||
});
|
||||
|
||||
const windows = this.props.sources
|
||||
.filter((source) => {
|
||||
return source.id.startsWith("window");
|
||||
})
|
||||
.map((source) => {
|
||||
return <DesktopCapturerSource source={source} onSelect={this.onSelect} key={source.id} />;
|
||||
});
|
||||
|
||||
return (
|
||||
<BaseDialog className="mx_streamSelectorDialog">
|
||||
<h1>{_td("Screens")}</h1>
|
||||
<div className="desktop-capturer-selection-scroller">
|
||||
{ screens }
|
||||
</div>
|
||||
<h1>{_td("Windows")}</h1>
|
||||
<div className="desktop-capturer-selection-scroller">
|
||||
{ windows }
|
||||
</div>
|
||||
</BaseDialog>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue