2017-10-12 10:00:28 +08:00
|
|
|
import Screenshare from '/imports/api/screenshare';
|
2017-11-11 11:41:37 +08:00
|
|
|
import KurentoBridge from '/imports/api/screenshare/client/bridge';
|
2020-05-15 00:36:03 +08:00
|
|
|
import BridgeService from '/imports/api/screenshare/client/bridge/service';
|
2019-05-29 04:46:29 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2019-11-15 00:35:56 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2019-11-15 03:07:35 +08:00
|
|
|
import { tryGenerateIceCandidates } from '/imports/utils/safari-webrtc';
|
2019-12-19 05:40:04 +08:00
|
|
|
import { stopWatching } from '/imports/ui/components/external-video-player/service';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2020-09-10 22:11:18 +08:00
|
|
|
import UserListService from '/imports/ui/components/user-list/service';
|
Correctly set audio input/output devices
When refusing ("thumbs down" button) echo test, user is able to select a different input device. This should work fine for chrome, firefox and safari (once user grants permission when asked by html5client).
For output devices, we depend on setSinkId function, which is enabled by default on current chrome release (2020) but not in Firefox (user needs to enable "setSinkId in about:config page). This implementation is listed as (?) in MDN.
In other words, output device selection should work out of the box for chrome, only.
When selecting an outputDevice, all alert sounds (hangup, screenshare , polling, etc) also goes to the same output device.
This solves #10592
2020-10-07 07:37:55 +08:00
|
|
|
import AudioService from '/imports/ui/components/audio/service';
|
2017-07-25 03:29:34 +08:00
|
|
|
|
|
|
|
// when the meeting information has been updated check to see if it was
|
|
|
|
// screensharing. If it has changed either trigger a call to receive video
|
|
|
|
// and display it, or end the call and hide the video
|
2017-11-06 23:39:55 +08:00
|
|
|
const isVideoBroadcasting = () => {
|
2020-08-27 03:53:23 +08:00
|
|
|
const screenshareEntry = Screenshare.findOne({ meetingId: Auth.meetingID },
|
|
|
|
{ fields: { 'screenshare.stream': 1 } });
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2020-08-27 03:53:23 +08:00
|
|
|
if (!screenshareEntry) {
|
2017-07-26 04:56:40 +08:00
|
|
|
return false;
|
|
|
|
}
|
2017-09-09 01:00:00 +08:00
|
|
|
|
2020-08-27 03:53:23 +08:00
|
|
|
return !!screenshareEntry.screenshare.stream;
|
2019-03-09 03:41:19 +08:00
|
|
|
};
|
2017-07-25 03:29:34 +08:00
|
|
|
|
|
|
|
// if remote screenshare has been ended disconnect and hide the video stream
|
2017-11-06 23:39:55 +08:00
|
|
|
const presenterScreenshareHasEnded = () => {
|
2017-09-09 01:00:00 +08:00
|
|
|
// references a function in the global namespace inside kurento-extension.js
|
2017-07-25 03:29:34 +08:00
|
|
|
// that we load dynamically
|
2017-09-09 01:00:00 +08:00
|
|
|
KurentoBridge.kurentoExitVideo();
|
2019-03-09 03:41:19 +08:00
|
|
|
};
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2020-08-27 07:30:53 +08:00
|
|
|
const viewScreenshare = () => {
|
|
|
|
const amIPresenter = UserListService.isUserPresenter(Auth.userID);
|
|
|
|
if (!amIPresenter) {
|
2020-09-10 22:12:44 +08:00
|
|
|
KurentoBridge.kurentoViewScreen();
|
2020-08-27 07:30:53 +08:00
|
|
|
} else {
|
|
|
|
KurentoBridge.kurentoViewLocalPreview();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-25 03:29:34 +08:00
|
|
|
// if remote screenshare has been started connect and display the video stream
|
2017-11-06 23:39:55 +08:00
|
|
|
const presenterScreenshareHasStarted = () => {
|
2019-11-15 00:35:56 +08:00
|
|
|
// WebRTC restrictions may need a capture device permission to release
|
|
|
|
// useful ICE candidates on recvonly/no-gUM peers
|
|
|
|
tryGenerateIceCandidates().then(() => {
|
2020-08-27 07:30:53 +08:00
|
|
|
viewScreenshare();
|
2019-11-15 03:07:35 +08:00
|
|
|
}).catch((error) => {
|
2019-11-15 00:35:56 +08:00
|
|
|
logger.error({
|
|
|
|
logCode: 'screenshare_no_valid_candidate_gum_failure',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
2019-11-15 03:07:35 +08:00
|
|
|
},
|
2019-11-15 00:35:56 +08:00
|
|
|
}, `Forced gUM to release additional ICE candidates failed due to ${error.name}.`);
|
|
|
|
// The fallback gUM failed. Try it anyways and hope for the best.
|
2020-08-27 07:30:53 +08:00
|
|
|
viewScreenshare();
|
2019-11-15 00:35:56 +08:00
|
|
|
});
|
2019-03-09 03:41:19 +08:00
|
|
|
};
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2018-08-23 02:10:08 +08:00
|
|
|
const shareScreen = (onFail) => {
|
2019-12-19 05:40:04 +08:00
|
|
|
// stop external video share if running
|
|
|
|
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
|
|
|
|
if (meeting && meeting.externalVideoUrl) {
|
|
|
|
stopWatching();
|
|
|
|
}
|
|
|
|
|
2020-05-26 01:32:24 +08:00
|
|
|
BridgeService.getScreenStream().then((stream) => {
|
2020-05-15 00:36:03 +08:00
|
|
|
KurentoBridge.kurentoShareScreen(onFail, stream);
|
|
|
|
}).catch(onFail);
|
2019-03-09 03:41:19 +08:00
|
|
|
};
|
2017-09-13 04:47:06 +08:00
|
|
|
|
Correctly set audio input/output devices
When refusing ("thumbs down" button) echo test, user is able to select a different input device. This should work fine for chrome, firefox and safari (once user grants permission when asked by html5client).
For output devices, we depend on setSinkId function, which is enabled by default on current chrome release (2020) but not in Firefox (user needs to enable "setSinkId in about:config page). This implementation is listed as (?) in MDN.
In other words, output device selection should work out of the box for chrome, only.
When selecting an outputDevice, all alert sounds (hangup, screenshare , polling, etc) also goes to the same output device.
This solves #10592
2020-10-07 07:37:55 +08:00
|
|
|
const screenShareEndAlert = () => AudioService
|
|
|
|
.playAlertSound(`${Meteor.settings.public.app.cdn
|
|
|
|
+ Meteor.settings.public.app.basename}`
|
|
|
|
+ '/resources/sounds/ScreenshareOff.mp3');
|
2019-06-13 02:40:58 +08:00
|
|
|
|
2017-11-06 23:39:55 +08:00
|
|
|
const unshareScreen = () => {
|
|
|
|
KurentoBridge.kurentoExitScreenShare();
|
2019-04-16 05:39:07 +08:00
|
|
|
screenShareEndAlert();
|
2019-03-09 03:41:19 +08:00
|
|
|
};
|
2017-07-25 03:29:34 +08:00
|
|
|
|
2019-05-29 04:46:29 +08:00
|
|
|
const dataSavingSetting = () => Settings.dataSaving.viewScreenshare;
|
2019-04-16 05:39:07 +08:00
|
|
|
|
2017-07-25 03:29:34 +08:00
|
|
|
export {
|
2019-03-09 03:41:19 +08:00
|
|
|
isVideoBroadcasting,
|
|
|
|
presenterScreenshareHasEnded,
|
|
|
|
presenterScreenshareHasStarted,
|
|
|
|
shareScreen,
|
2019-04-16 05:39:07 +08:00
|
|
|
screenShareEndAlert,
|
2019-06-13 02:40:58 +08:00
|
|
|
unshareScreen,
|
2019-05-29 04:46:29 +08:00
|
|
|
dataSavingSetting,
|
2017-07-25 03:29:34 +08:00
|
|
|
};
|