--- /dev/null
+node_modules/
--- /dev/null
+{
+ "ecmaVersion": 6,
+ "libs": [],
+ "loadEagerly": [],
+ "dontLoad": [
+ "node_modules/**"
+ ],
+ "plugins": {
+ "doc_comment": true,
+ "node": {
+ "dontLoad": "",
+ "load": "",
+ "modules": ""
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+# electron-quick-start
+
+**Clone and run for a quick way to see Electron in action.**
+
+This is a minimal Electron application based on the [Quick Start Guide](http://electron.atom.io/docs/tutorial/quick-start) within the Electron documentation.
+
+**Use this app along with the [Electron API Demos](http://electron.atom.io/#get-started) app for API code examples to help you get started.**
+
+A basic Electron application needs just these files:
+
+- `package.json` - Points to the app's main file and lists its details and dependencies.
+- `main.js` - Starts the app and creates a browser window to render HTML. This is the app's **main process**.
+- `index.html` - A web page to render. This is the app's **renderer process**.
+
+You can learn more about each of these components within the [Quick Start Guide](http://electron.atom.io/docs/tutorial/quick-start).
+
+## To Use
+
+To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line:
+
+```bash
+# Clone this repository
+git clone https://github.com/electron/electron-quick-start
+# Go into the repository
+cd electron-quick-start
+# Install dependencies
+npm install
+# Run the app
+npm start
+```
+
+Note: If you're using Linux Bash for Windows, [see this guide](https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/) or use `node` from the command prompt.
+
+## Resources for Learning Electron
+
+- [electron.atom.io/docs](http://electron.atom.io/docs) - all of Electron's documentation
+- [electron.atom.io/community/#boilerplates](http://electron.atom.io/community/#boilerplates) - sample starter apps created by the community
+- [electron/electron-quick-start](https://github.com/electron/electron-quick-start) - a very basic starter Electron app
+- [electron/simple-samples](https://github.com/electron/simple-samples) - small applications with ideas for taking them further
+- [electron/electron-api-demos](https://github.com/electron/electron-api-demos) - an Electron app that teaches you how to use Electron
+- [hokein/electron-sample-apps](https://github.com/hokein/electron-sample-apps) - small demo apps for the various Electron APIs
+
+## License
+
+[CC0 1.0 (Public Domain)](LICENSE.md)
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Hello World!</title>
+ </head>
+ <body>
+ <h1>Click 'start' to begin screen sharing</h1>
+ <select id="streamList">
+ </select>
+ <button id="streams"> List of streams to choose from </button>
+ <video autoplay></video>
+
+ </body>
+
+ <script src="http://127.0.0.1:5140/admin.js"></script>
+
+</html>
--- /dev/null
+function makeRequest() {
+console.log('Making ajax request')
+ httpRequest = new XMLHttpRequest();
+
+ if (!httpRequest) {
+ alert('Giving up :( Cannot create an XMLHTTP instance');
+ return false;
+ }
+ httpRequest.open('GET', 'http://127.0.0.1:5140/streamlist');
+ httpRequest.onreadystatechange = function(e) {
+ if (request.readyState === 4) {
+ if (request.status === 200) {
+ console.log(request.responseText)
+ }
+ }
+ }
+ httpRequest.send()
+}
+
+
+document.addEventListener('DOMContentLoaded', function() {
+ let streamlist = document.getElementById("streamlist")
+ console.log('Document is ready')
+ document.getElementById("streams").addEventListener('click', makeRequest);
+})
--- /dev/null
+const electron = require('electron')
+const http = require('http')
+const path = require('path')
+const url = require('url')
+const fs = require('fs')
+const app = electron.app
+const BrowserWindow = electron.BrowserWindow
+const ipcMain = electron.ipcMain
+
+let mainWindow
+
+function beginRendererProcess() {
+ mainWindow = new BrowserWindow({show: true, webPreferences: { webSecurity: false, experimentalFeatures: true}})
+ mainWindow.loadURL(url.format({
+ pathname: path.join(__dirname, 'renderer.html'),
+ protocol: 'file:',
+ slashes: true
+ }))
+ mainWindow.webContents.openDevTools()
+}
+
+function captureStream() {
+ mainWindow.webContents.send('defaultStreamRequest', 'slr')
+ let p = new Promise((resolve,reject) => {
+ ipcMain.on('defaultStreamResponse', (event, arg) => {
+ console.log('defaultStreamResponse')
+ console.log(arg)
+ resolve(arg)
+ })
+ })
+
+ return p
+}
+
+
+const routes = {
+ '/': function root(response) {
+ response.write(fs.readFileSync('admin.html'))
+ response.end()
+ },
+ '/admin.js': function js(response) {
+ response.write(fs.readFileSync('admin.js'))
+ response.end()
+ },
+ '/admin.css': function css(response) {
+ response.write(fs.readFileSync('admin.css'))
+ response.end()
+ },
+ '/favicon.ico': function favicon() {
+ return 'strapp'
+ response.end()
+ },
+ '/streamlist': function streamlist(response) {
+ let mediaStream = captureStream().then((stream) => {
+ console.log(stream)
+ })
+
+ //response.write(mediaStream)
+ }
+}
+
+app.on('ready', function() {
+ beginRendererProcess()
+
+
+ http.createServer(function(request, response) {
+ const url = request.url
+ console.log('routing to ' + url);
+ routes[url](response)
+
+ }).listen(5140);
+});
--- /dev/null
+{
+ "name": "strapp",
+ "version": "0.0.0",
+ "description": "A distributed desktop sharer",
+ "main": "main.js",
+ "scripts": {
+ "start": "electron ."
+ },
+ "repository": "",
+ "keywords": [
+ "WebRTC",
+ "Cool",
+ "Screen Sharing",
+ "Distributed",
+ "Prototype"
+ ],
+ "author": "Jordan Lavatai",
+ "license": "MIT",
+ "devDependencies": {
+ "electron": "~1.6.2"
+ }
+}
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ </body>
+ <script src="renderer.js"></script>
+</html>
--- /dev/null
+const ipcRenderer = require('electron').ipcRenderer
+const {desktopCapturer} = require('electron')
+
+
+function getDefaultStream(event) {
+ console.log('getDefaultStream')
+ desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => {
+ if (error) {
+ console.log(error)
+ return
+ }
+ for (let i = 0; i < sources.length; ++i) {
+ if (sources[i].name === 'Screen 1') {
+ navigator.mediaDevices.getUserMedia({
+ audio: false,
+ video: {
+ mandatory: {
+ chromeMediaSource: 'desktop',
+ chromeMediaSourceId: sources[i].id,
+ minWidth: 1280,
+ maxWidth: 1280,
+ minHeight: 720,
+ maxHeight: 720
+ }
+ }
+ }).then((stream) => {
+ console.log(stream)
+ event.sender.send('defaultStreamResponse', stream)
+ })
+ }
+ }
+ return
+ })
+}
+
+ipcRenderer.on('defaultStreamRequest', (event, message) => {
+ console.log('defaultStreamRequest received, grabbing media stream for screen1')
+ getDefaultStream(event)
+})