New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-website-to-camera

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-website-to-camera - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

ScreenshotHelper.js

77

CameraSource.js
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc