Skip to content

Commit

Permalink
Cleanup appRaspi.js, and startH264player.sh
Browse files Browse the repository at this point in the history
Update node_modules (again) for FRC 2020.
  • Loading branch information
Raspi Config committed Jan 31, 2020
1 parent 654f27a commit 34db3d1
Show file tree
Hide file tree
Showing 53 changed files with 572 additions and 407 deletions.
16 changes: 14 additions & 2 deletions h264player/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# video notes
# installation

Currently this has been tested on FRCVision 2020 with
the addition of the standard node (10.15.2) and npm (5.8.0)
distros. (nb: npm whines about incompatibility, but this can
be safely ignored). Most significant npm dependency is express
but package.json says it all. If the checked-in node_modules
are incompatible with your node installation, simply remove the
directory and issue: `npm install`.

# on selecting h264player

H264 is a very efficient video solution on raspberry pi due to
its GPU-based implementation. The hard part is delivering
Expand All @@ -12,6 +22,7 @@ take place, but to make the pixels visible in the browser
we employ a javascript h264 decoder. Once the pixels
are decoded we rely on an opengl canvas. No use of
the more modern html5 video element here.

* webRTC is the newest and shiniest of streaming techs.
It resolved the biggest issue for broad-deployment of
streaming through a complex routing negotiation system
Expand All @@ -21,6 +32,7 @@ a native h264 decoder. But it failed for us in the
context of the FRC Field Management System. Since we have
very little time operating in that environment it is
very difficult to diagnose and resolve the problem.

* rtsp is an older tech for streaming that doesn't
appear to "gel" with browsers. It does appear to have
the same advantages (over webrtc) that h264player does.
Expand All @@ -37,4 +49,4 @@ it includes:
webRTCSignaling was derived from and is for use with uv4l.

an opensource webRTC + pi solution is https://github.com/kclyu/rpi-webrt
and is preferred over the closed-source uv4l.
and may be preferred over the closed-source uv4l.
98 changes: 43 additions & 55 deletions h264player/appRaspi.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,62 @@
"use strict";

/**
* Run this on a raspberry pi
* then browse (using google chrome/firefox) to http://[pi ip]:5085/
*/
const port = 5805; // legal port for competition FMS
const os = require('os');
const ifaces = os.networkInterfaces();
const http = require('http');
const express = require('express');
const os = require('os');
const ifaces = os.networkInterfaces();
const WebStreamerServer = require('./serverRaspi');
const app = express();
let ip = undefined;
const os = require('os');

//public website
app.use(express.static(__dirname + '/www'));
const server = http.createServer(app);
const silence = new WebStreamerServer(server);
const ip = undefined;
doit();

// find our IPv4 address
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].foreach(function(iface) {
if(iface.family == "IPv4" && iface.internal == false)
{
if(ip == undefined)
{
ip = iface.address;
return;
}
else
{
console.log("multiple ip addresses, ignoring: " +
iface.address);
}
}
});
});
function doit()
{
let ip = getIP();

const app = express();
const server = http.createServer(app);
const silence = new WebStreamerServer(server);
app.use(express.static(__dirname + '/www')); // public website

// start the server on a single interface
try
{
console.log(`appRaspi listening on ${ip}:${port}`);
server.listen(port, ip); //
}

// find our IPv4 address
console.log("interfaces:\n");
for(let ifname of Object.keys(ifaces))
catch(err)
{
console.log("appRaspi error: " + err.message);
}
}

function getIP()
{
for(let iface of ifaces[ifname])
// find our IPv4 address
const ifaces = os.networkInterfaces();
let ip = undefined;

console.log("host interfaces discovered:");
for(let ifname of Object.keys(ifaces))
{
console.log(`${ifname} ${iface.family} ip:${iface.address}`);
if(iface.family == "IPv4" && iface.internal == false)
for(let iface of ifaces[ifname])
{
if(ip == undefined)
{
ip = iface.address;
}
else
console.log(` ${ifname} ${iface.family} ip:${iface.address}`);
if(iface.family == "IPv4" && iface.internal == false)
{
console.log("multiple ip addresses, ignoring: " +
iface.address);
if(ip == undefined)
{
ip = iface.address;
}
else
{
console.log(" Multiple IPv4 addresses, ignoring: " +
iface.address);
}
}
}
}
}

try
{
console.log(`appRaspi listening on ${ip}:${port}`);
server.listen(port, ip); //
}

catch(err)
{
console.log("appRaspi error: " + err.message);
return ip;
}
23 changes: 13 additions & 10 deletions h264player/node_modules/accepts/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions h264player/node_modules/array-flatten/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions h264player/node_modules/body-parser/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions h264player/node_modules/bytes/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions h264player/node_modules/content-disposition/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 34db3d1

Please sign in to comment.