homebridge-website-to-camera
Advanced tools
Comparing version 1.0.8 to 1.1.0
"use strict"; | ||
var ip = require("ip"); | ||
var crypto = require("crypto"); | ||
var capture = require("capture-phantomjs"); | ||
let ip = require("ip"); | ||
let crypto = require("crypto"); | ||
let screenshotHelper = require("./ScreenshotHelper"); | ||
@@ -19,3 +19,3 @@ module.exports = Camera; | ||
var options = { | ||
let options = { | ||
proxy: false, // Requires RTP/RTCP MUX Proxy | ||
@@ -62,9 +62,3 @@ disable_audio_proxy: false, // If proxy = true, you can opt out audio proxy via this | ||
Camera.prototype.handleSnapshotRequest = function (request, callback) { | ||
capture({ | ||
url: this.conf.url, | ||
width: this.conf.width || 640, | ||
height: this.conf.height || 360, | ||
wait: this.conf.renderDelay || 0, | ||
format: "jpg" | ||
}) | ||
screenshotHelper.getScreenshot(this.conf.url, this.conf.width || 640, this.conf.height || 360, this.conf.chromiumPath) | ||
.then( | ||
@@ -87,23 +81,21 @@ img => { | ||
// Invoked when iOS device requires stream | ||
var sessionInfo = {}; | ||
let sessionInfo = {}; | ||
var sessionID = request.sessionID; | ||
var targetAddress = request.targetAddress; | ||
let sessionID = request.sessionID; | ||
sessionInfo.address = request.targetAddress; | ||
sessionInfo.address = targetAddress; | ||
let response = {}; | ||
var response = {}; | ||
var videoInfo = request.video; | ||
let videoInfo = request.video; | ||
if (videoInfo) { | ||
var targetPort = videoInfo.port; | ||
var srtpKey = videoInfo.srtp_key; | ||
var srtpSalt = videoInfo.srtp_salt; | ||
let targetPort = videoInfo.port; | ||
let srtpKey = videoInfo.srtp_key; | ||
let srtpSalt = videoInfo.srtp_salt; | ||
// SSRC is a 32 bit integer that is unique per stream | ||
var ssrcSource = crypto.randomBytes(4); | ||
let ssrcSource = crypto.randomBytes(4); | ||
ssrcSource[0] = 0; | ||
var ssrc = ssrcSource.readInt32BE(0, true); | ||
let ssrc = ssrcSource.readInt32BE(0, true); | ||
var videoResp = { | ||
response.video = { | ||
port: targetPort, | ||
@@ -115,4 +107,2 @@ ssrc: ssrc, | ||
response.video = videoResp; | ||
sessionInfo.video_port = targetPort; | ||
@@ -123,14 +113,14 @@ sessionInfo.video_srtp = Buffer.concat([srtpKey, srtpSalt]); | ||
var audioInfo = request.audio; | ||
let audioInfo = request.audio; | ||
if (audioInfo) { | ||
var targetPort = audioInfo.port; | ||
var srtpKey = audioInfo.srtp_key; | ||
var srtpSalt = audioInfo.srtp_salt; | ||
let targetPort = audioInfo.port; | ||
let srtpKey = audioInfo.srtp_key; | ||
let srtpSalt = audioInfo.srtp_salt; | ||
// SSRC is a 32 bit integer that is unique per stream | ||
var ssrcSource = crypto.randomBytes(4); | ||
let ssrcSource = crypto.randomBytes(4); | ||
ssrcSource[0] = 0; | ||
var ssrc = ssrcSource.readInt32BE(0, true); | ||
let ssrc = ssrcSource.readInt32BE(0, true); | ||
var audioResp = { | ||
response.audio = { | ||
port: targetPort, | ||
@@ -142,4 +132,2 @@ ssrc: ssrc, | ||
response.audio = audioResp; | ||
sessionInfo.audio_port = targetPort; | ||
@@ -150,4 +138,4 @@ sessionInfo.audio_srtp = Buffer.concat([srtpKey, srtpSalt]); | ||
var currentAddress = ip.address(); | ||
var addressResp = { | ||
let currentAddress = ip.address(); | ||
let addressResp = { | ||
address: currentAddress | ||
@@ -169,8 +157,8 @@ }; | ||
Camera.prototype.handleStreamRequest = function (request) { | ||
var sessionID = request.sessionID; | ||
var requestType = request.type; | ||
let sessionID = request.sessionID; | ||
let requestType = request.type; | ||
if (!sessionID) { | ||
return; | ||
} | ||
var sessionIdentifier = this.hap.uuid.unparse(sessionID); | ||
let sessionIdentifier = this.hap.uuid.unparse(sessionID); | ||
@@ -190,3 +178,3 @@ if (requestType === "start" && this.pendingSessions[sessionIdentifier]) { | ||
Camera.prototype.createCameraControlService = function () { | ||
var controlService = new this.hap.Service.CameraControl(); | ||
let controlService = new this.hap.Service.CameraControl(); | ||
this.services.push(controlService); | ||
@@ -196,5 +184,5 @@ }; | ||
Camera.prototype._createStreamControllers = function (maxStreams, options) { | ||
var self = this; | ||
for (var i = 0; i < maxStreams; i += 1) { | ||
var streamController = new this.hap.StreamController(i, options, self); | ||
let self = this; | ||
for (let i = 0; i < maxStreams; i += 1) { | ||
let streamController = new this.hap.StreamController(i, options, self); | ||
self.services.push(streamController.service); | ||
@@ -204,2 +192,1 @@ self.streamControllers.push(streamController); | ||
}; | ||
{ | ||
"name": "homebridge-website-to-camera", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"description": "shows the screenshot of a website as camera (image)", | ||
@@ -35,4 +35,4 @@ "main": "index.js", | ||
"ip": "^1.1.5", | ||
"capture-phantomjs": "^1.4.2" | ||
"puppeteer": "^1.5.0" | ||
} | ||
} |
@@ -12,33 +12,9 @@ # homebridge-website-to-camera | ||
1. (Install Homebridge using: `(sudo) npm install -g --unsafe-perm homebridge` if you haven't already) | ||
Make sure you have homebridge installed. | ||
## Raspberry Pi and any other ARM | ||
Currently I couldn't find a proper solution for installing the plugin on raspberry-pi (Help wanted!) so unfortunately you have to | ||
use this hacky workaround | ||
2. Download the latest [phantomjs-on-raspberry](https://github.com/fg2it/phantomjs-on-raspberry) | ||
* `wget https://github.com/fg2it/phantomjs-on-raspberry/releases/download/v2.1.1-wheezy-jessie-armv6/phantomjs_2.1.1_armhf.deb` | ||
* `sudo dpkg -i phantomjs_2.1.1_armhf.deb` | ||
3. Find your npm-root: | ||
* `npm root -g` | ||
* probably the output will be `/usr/lib/node_modules` | ||
3. Install this plugin with git: | ||
* `cd /usr/lib/node_modules` | ||
* `sudo git clone https://github.com/werthdavid/homebridge-website-to-camera.git` | ||
* `cd homebridge-website-to-camera` | ||
* `sudo npm install` | ||
1. Download the latest Chromium `sudo apt-get install chromium-browser` | ||
3. Install this plugin using: ` echo "export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && npm install -g homebridge-website-to-camera" | sudo sh` | ||
4. Update your Homebridge `config.json` using the sample below (append in the block 'platforms' not 'accessories') | ||
## x86/x64 | ||
2. Install this plugin using: `(sudo) npm install -g homebridge-website-to-camera` | ||
3. Update your Homebridge `config.json` using the sample below (append in the block 'platforms' not 'accessories') | ||
# Configuration | ||
@@ -48,12 +24,12 @@ | ||
```json | ||
"platforms":[ | ||
"platforms": [ | ||
{ | ||
"platform":"website-camera", | ||
"cameras":[ | ||
"platform": "website-camera", | ||
"cameras": [ | ||
{ | ||
"name":"Website 1", | ||
"url":"http://github.com", | ||
"width":800, | ||
"height":400, | ||
"renderDelay":1500 | ||
"name": "Website 1", | ||
"url": "http://github.com", | ||
"width": 800, | ||
"height": 400, | ||
"chromiumPath": "/usr/bin/chromium-browser" | ||
} | ||
@@ -74,6 +50,6 @@ ] | ||
* `name` name of the camera (required) | ||
* `url` the URL of the website that is to be captured | ||
* `width` the width of the virtual browser window | ||
* `height` the height of the virtual browser window | ||
* `renderDelay` time in ms that is waited after loading the URL before screenshot is taken (increase if image is incomplete) | ||
* `url` the URL of the website that is to be captured (required) | ||
* `width` the width of the virtual browser window (defaults to 640) | ||
* `height` the height of the virtual browser window (defaults to 360) | ||
* `chromiumPath` path to chromium-executable (defaults to "/usr/bin/chromium-browser") | ||
@@ -89,5 +65,8 @@ | ||
# Background | ||
The plugin uses Puppeteer/Chrome headless to capture the screenshots. The Browser instance stays open all the time for better performance and less CPU/Mem consumption. | ||
# TODO | ||
* Probably we should use Chrome-Headless/Puppeteer in later versions | ||
* Live-Video not working yet |
10
240
1809337
68
+ Addedpuppeteer@^1.5.0
+ Addedagent-base@4.3.0(transitive)
+ Addedasync-limiter@1.0.1(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addeddebug@2.6.93.2.74.4.0(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-promisify@5.0.0(transitive)
+ Addedextract-zip@1.7.0(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedhttps-proxy-agent@2.2.4(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedpuppeteer@1.20.0(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedws@6.2.3(transitive)
+ Addedyauzl@2.10.0(transitive)
- Removedcapture-phantomjs@^1.4.2
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@0.2.01.0.0(transitive)
- Removedasync@2.6.4(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbl@1.0.3(transitive)
- Removedboom@2.10.1(transitive)
- Removedcapture-phantomjs@1.4.5(transitive)
- Removedcaseless@0.11.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommander@2.20.3(transitive)
- Removedconcat-stream@1.5.0(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@0.7.4(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedextend@3.0.2(transitive)
- Removedextract-zip@1.5.0(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfd-slicer@1.0.1(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@1.0.1(transitive)
- Removedfs-extra@0.26.7(transitive)
- Removedgenerate-function@2.3.1(transitive)
- Removedgenerate-object-property@1.2.0(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhar-validator@2.0.6(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhasha@2.2.0(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedis-my-ip-valid@1.0.1(transitive)
- Removedis-my-json-valid@2.20.6(transitive)
- Removedis-property@1.0.2(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonfile@2.4.0(transitive)
- Removedjsonpointer@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedkew@0.7.0(transitive)
- Removedklaw@1.3.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.5.0(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedphantomjs@2.1.7(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprocess-nextick-args@1.0.7(transitive)
- Removedprogress@1.1.8(transitive)
- Removedqs@5.2.1(transitive)
- Removedreadable-stream@2.0.6(transitive)
- Removedrequest@2.67.0(transitive)
- Removedrequest-progress@2.0.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedshell-escape@0.2.0(transitive)
- Removedsntp@1.0.9(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedthrottleit@1.0.1(transitive)
- Removedtough-cookie@2.2.2(transitive)
- Removedtunnel-agent@0.4.3(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedtypedarray@0.0.7(transitive)
- Removedverror@1.10.0(transitive)
- Removedwhich@1.2.14(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyauzl@2.4.1(transitive)