diff options
Diffstat (limited to 'vid/src/main/webapp/app/fusion/scripts/webrtc/getSourceId.html')
-rw-r--r-- | vid/src/main/webapp/app/fusion/scripts/webrtc/getSourceId.html | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/vid/src/main/webapp/app/fusion/scripts/webrtc/getSourceId.html b/vid/src/main/webapp/app/fusion/scripts/webrtc/getSourceId.html deleted file mode 100644 index 6f660025..00000000 --- a/vid/src/main/webapp/app/fusion/scripts/webrtc/getSourceId.html +++ /dev/null @@ -1,78 +0,0 @@ - -<script> - -var DetectRTC = {}; - -var screenCallback; - -DetectRTC.screen = { - chromeMediaSource: 'screen', - getSourceId: function (callback) { - screenCallback = callback; - window.postMessage('get-sourceId', '*'); - }, - onMessageCallback: function (data) { - // "cancel" button is clicked - if (data == 'PermissionDeniedError') { - DetectRTC.screen.chromeMediaSource = 'PermissionDeniedError'; - if (screenCallback) return screenCallback('PermissionDeniedError'); - else throw new Error('PermissionDeniedError'); - } - - // extension notified his presence - if (data == 'rtcmulticonnection-extension-loaded') { - DetectRTC.screen.chromeMediaSource = 'desktop'; - } - - // extension shared temp sourceId - if (data.sourceId) { - DetectRTC.screen.sourceId = data.sourceId; - if (screenCallback) screenCallback(DetectRTC.screen.sourceId); - } - }, - getChromeExtensionStatus: function (callback) { - // https://chrome.google.com/webstore/detail/screen-capturing-private/icgmlogfeajbfdffajhoebcfbibfhaen - var extensionid = 'icgmlogfeajbfdffajhoebcfbibfhaen'; - - var image = document.createElement('img'); - image.src = 'chrome-extension://' + extensionid + '/icon.png'; - image.onload = function () { - DetectRTC.screen.chromeMediaSource = 'screen'; - window.postMessage('are-you-there', '*'); - setTimeout(function () { - if (DetectRTC.screen.chromeMediaSource == 'screen') { - callback('installed-disabled'); - } else callback('installed-enabled'); - }, 2000); - }; - image.onerror = function () { - callback('not-installed'); - }; - } -}; - -window.addEventListener('message', function (event) { - if (!event.data || !(typeof event.data == 'string' || event.data.sourceId || event.data.captureSourceId)) return; - if (event.data.captureSourceId) captureSourceId(); - - DetectRTC.screen.onMessageCallback(event.data); -}); - -function captureSourceId() { - // check if desktop-capture extension installed. - DetectRTC.screen.getChromeExtensionStatus(function (status) { - if (status != 'installed-enabled') { - window.parent.postMessage({ - chromeExtensionStatus: status - }, '*'); - return; - } - - DetectRTC.screen.getSourceId(function (sourceId) { - window.parent.postMessage({ - chromeMediaSourceId: sourceId - }, '*'); - }); - }); -} -</script> |