Merge pull request #161 from SimonBrandner/fix-screen-sharing

Fix desktop Matrix screen sharing
This commit is contained in:
David Baker 2021-02-08 13:54:57 +00:00 committed by GitHub
commit 8828838e8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
const { contextBridge, ipcRenderer } = require("electron");
const { ipcRenderer, desktopCapturer, contextBridge } = require('electron');
// Expose only expected IPC wrapper APIs to the renderer process to avoid
// handing out generalised messaging access.
@ -53,5 +53,19 @@ contextBridge.exposeInMainWorld(
}
ipcRenderer.send(channel, ...args);
},
async getDesktopCapturerSources(options) {
const sources = await desktopCapturer.getSources(options);
const desktopCapturerSources = [];
for (const source of sources) {
desktopCapturerSources.push({
id: source.id,
name: source.name,
thumbnailURL: source.thumbnail.toDataURL(),
});
}
return desktopCapturerSources;
},
},
);