Permalink
Browse files

Manually merged Paul's Nest streaming support:

    camera.js: capture images continuously from cameraURI.

    This is basically just for Nest IP camera because its API doesn't
    support real streaming. It can be used with other IP cameras but since
    other cameras should have the direct way to access the real stream. Thus
    we don't suggest to use this for ordinary IP camera.

    Signed-off-by: Ying-Chun Liu (PaulLiu) paulliu@debian.org

Signed-off-by: Bofu Chen (bafu) <bofu@dt42.io>
  • Loading branch information...
Bofu Chen (bafu)
Bofu Chen (bafu) committed Sep 30, 2017
1 parent a3183ef commit 3c4568243b7061ffcd71ad4e798e9fc7a0af3218
Showing with 28 additions and 0 deletions.
  1. +7 −0 README.md
  2. +21 −0 camera.js
@@ -103,6 +103,13 @@ $ mosquitto_pub -h localhost -t berrynet/event/camera -m stream_boardcam_start
$ mosquitto_pub -h localhost -t berrynet/event/camera -m stream_boardcam_stop
```

To start and stop streaming from Nest IP camera

```
$ mosquitto_pub -h localhost -t berrynet/event/camera -m stream_nest_ipcam_start
$ mosquitto_pub -h localhost -t berrynet/event/camera -m stream_nest_ipcam_stop
```


# Enable Data Collector

@@ -142,6 +142,27 @@ client.on('message', (t, m) => {
clearInterval(cameraIntervalID);
cameraIntervalID = null;
}
} else if (action == 'stream_nest_ipcam_start') {
if (!cameraIntervalID) {
cameraIntervalID = setInterval(function() {
request.get(
{uri: cameraURI, encoding: null},
(e, res, body) => {
if (!e && res.statusCode == 200) {
log('camera client: publishing image.');
client.publish(topicActionInference, body);
} else {
log('camera client: cannot get image.');
}
}
);
}, cameraInterval);
}
} else if (action == 'stream_nest_ipcam_stop') {
if (cameraIntervalID) {
clearInterval(cameraIntervalID);
cameraIntervalID = null;
}
} else {
log('camera client: unkown action.');
}

0 comments on commit 3c45682

Please sign in to comment.