Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(screen-sharing) fix depredcated ss hook #369

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
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
55 changes: 32 additions & 23 deletions screensharing/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,32 @@ class ScreenShareRenderHook {
*/
async _onIframeApiLoad() {
// TODO: delete this after 2 releases
this._iframe.contentWindow.JitsiMeetElectron = {
/**
* Get sources available for screensharing. The callback is invoked
* with an array of DesktopCapturerSources.
*
* @param {Function} callback - The success callback.
* @param {Function} errorCallback - The callback for errors.
* @param {Object} options - Configuration for getting sources.
* @param {Array} options.types - Specify the desktop source types
* to get, with valid sources being "window" and "screen".
* @param {Object} options.thumbnailSize - Specify how big the
* preview images for the sources should be. The valid keys are
* height and width, e.g. { height: number, width: number}. By
* default electron will return images with height and width of
* 150px.
*/
obtainDesktopStreams(callback, errorCallback, options = {}) {
ipcRenderer.invoke(SCREEN_SHARE_GET_SOURCES, options)
.then((sources) => callback(sources))
.catch((error) => errorCallback(error));
}
};
try {
this._iframe.contentWindow.JitsiMeetElectron = {
/**
* Get sources available for screensharing. The callback is invoked
* with an array of DesktopCapturerSources.
*
* @param {Function} callback - The success callback.
* @param {Function} errorCallback - The callback for errors.
* @param {Object} options - Configuration for getting sources.
* @param {Array} options.types - Specify the desktop source types
* to get, with valid sources being "window" and "screen".
* @param {Object} options.thumbnailSize - Specify how big the
* preview images for the sources should be. The valid keys are
* height and width, e.g. { height: number, width: number}. By
* default electron will return images with height and width of
* 150px.
*/
obtainDesktopStreams(callback, errorCallback, options = {}) {
ipcRenderer.invoke(SCREEN_SHARE_GET_SOURCES, options)
.then((sources) => callback(sources))
.catch((error) => errorCallback(error));
}
};
} catch(_) {
logWarning('Failed to setup deprecated screen-sharing hook');
}

ipcRenderer.on(SCREEN_SHARE_EVENTS_CHANNEL, this._onScreenSharingEvent);
this._api.on('screenSharingStatusChanged', this._onScreenSharingStatusChanged);
Expand All @@ -87,7 +91,12 @@ class ScreenShareRenderHook {
const isNewElectronScreensharingSupported = await this._isNewElectronScreensharingSupported();

if (isNewElectronScreensharingSupported) {
this._iframe.contentWindow.JitsiMeetElectron = undefined;
try {
this._iframe.contentWindow.JitsiMeetElectron = undefined;
} catch(_) {
// Ignore.
}

this._api.on('_requestDesktopSources', async (request, callback) => {
const { options } = request;

Expand Down