Commit Graph

473 Commits

Author SHA1 Message Date
Scott Lamb 066c086050 style: use rusqlite's {named_,}params! everywhere 2020-03-19 20:46:25 -07:00
Scott Lamb 9d6dec2565 fix incorrect Javascript private variable style
It's supposed to be a trailing underscore, not a leading underscore, as
described here:

https://google.github.io/styleguide/jsguide.html#naming-method-names
https://google.github.io/styleguide/jsguide.html#naming-non-constant-field-names

and discussed in an earlier PR:

https://github.com/scottlamb/moonfire-nvr/pull/48#discussion_r175678736

I fixed these mechanically:

rg -l0 'this[.]_' | xargs -0 perl -pi -e 's/this[.]_(\w+)/this.$1_/g'
rg -l0 '\s_\w+\(' | xargs -0 perl -pi -e 's/_(\w+)\(/$1_(/g'
2020-03-14 15:20:18 -07:00
Scott Lamb 038aebe0fd javascript lint fix 2020-03-14 15:13:11 -07:00
Scott Lamb 3968bfe912 reorganize /recordings JSON response
I want to start returning the pixel aspect ratio of each video sample
entry. It's silly to duplicate it for each returned recording, so
let's instead return a videoSampleEntryId and then put all the
information about each VSE once.

This change doesn't actually handle pixel aspect ratio server-side yet.
Most likely I'll require a new schema version for that, to store it as a
new column in the database. Codec-specific logic in the database layer
is awkward and I'd like to avoid it. I did a similar schema change to
add the rfc6381_codec.

I also adjusted ui-src/lib/models/Recording.js in a few ways:

* fixed a couple mismatches between its field name and the key defined
  in the API. Consistency aids understanding.
* dropped all the getters in favor of just setting the fields (with
  type annotations) as described here:
  https://google.github.io/styleguide/jsguide.html#features-classes-fields
* where the wire format used undefined (to save space), translate it to
  a more natural null or false.
2020-03-13 21:41:02 -07:00
Scott Lamb 317a620e6e upgrade copyright notices
* As discussed in #48, say "The Moonfire NVR Authors" at the top of
  every file rather than whoever created that file. Have one AUTHORS
  file listing everyone.
* Consistently call it a "security camera network video recorder" rather
  than "security camera digital video recorder".
2020-03-01 22:53:41 -08:00
Scott Lamb fc77db0fc9 add autocomplete attributes to login form
The Chrome console was nagging about this, linking to here:
https://www.chromium.org/developers/design-documents/create-amazing-password-forms
I'm not sure it makes any real difference (autocomplete already worked),
but it's easy enough to do.
2020-03-01 22:36:04 -08:00
Scott Lamb aa25a85477 Fix a whole bunch of eslint errors
These apparently were silent until 92c532d mass-upgraded deps.
Apparently eslint returned status 0 despite errors before and now
returns 1.

Most of these were handled by its "--fix" option; I manually took care
of the remaining two:

/Users/slamb/git/moonfire-nvr/ui-src/lib/views/RecordingsView.js
  140:1  error  This line has a length of 82. Maximum allowed is 80  max-len

/Users/slamb/git/moonfire-nvr/ui-src/lib/views/StreamSelectorView.js
  72:1  error  This line has a length of 82. Maximum allowed is 80  max-len
2020-03-01 22:28:24 -08:00
Scott Lamb 92c532db3e upgrade minimum nodejs version, yarn dev deps
Looks like I basically had to do this to keep up. With nodejs version 12
(current LTS), the version of fsevents I installed wouldn't build. A
"yarn upgrade" by itself resulted in a new problem as described in #69.
Conversely, the new versions don't install with nodejs 8. So I bit the
bullet and upgraded all the dev dependency stuff and the nodejs at once.
nodejs 10 seems capable of running either the old or new, fwiw.

I'm a little sad that this seems to have made the UI bundle 5% larger.
Before, "yarn build" said 350 KiB. After, 369 KiB. A little bit in
several places. For example, jquery-ui.bundle.js went from 156 KiB (in
2 chunks) to 160 KiB (in 1 chunk) for some reason.
2020-03-01 21:57:51 -08:00
Scott Lamb b298bd13f2 grab one minimizer rather than three
Apparently WebPack builds in "terser", which is what the cool kids use.
Just go with the default and simplify the configuration as well as
installing fewer node modules.

"babel-minify-webpack-plugin" wasn't actually being used, and
babel-minify is still in beta anyway.

uglifyjs, according to https://github.com/webpack/webpack/issues/7923,
doesn't support ES6 and depends on a package which is no longer
maintained.
2020-03-01 21:23:29 -08:00
Scott Lamb 4b397670a4 revamp webpack config
* simplify it. Go from six checked-in config files + one local one to
  three checked-in configs + commandline options. I find it less
  confusing to have the options plumbed through fewer layers.

* support developing against a https production server, as described in
  guide/developing-ui.md.

* fix the source map. The sourceMap parameter in prod.config.js as far
  as I can tell evaluated to false when run with production config, and
  anyway UglifyJS seems to be incompatible with the specified
  cheap-module-source-map. Use source-map instead.
2020-03-01 19:26:45 -08:00
Scott Lamb 92266612b5 switch to websocket for live stream (#59)
The multipart stream / hanging GET approach worked in a prototype for a
single stream, but Chrome has a per-host limit of six connections. If I
try streaming all my cameras at once, I hit that limit. I can't open all
the streams, much less additional connections to load init segments and
such. Websockets apparently has a much higher limit of 256.
2020-02-29 14:39:16 -08:00
Scott Lamb 3fa48ab0da remove the JsonWrapper class
Let's follow the Google Style Guide, in which private variables are
simply suffixed with "_". It's a sign, not a cop, but that's fine.
I'd rather keep things simple, and code review should suffice for
catching uses of a private variable outside the class.
2020-02-22 21:15:37 -08:00
Scott Lamb a26c3d1649 fix some reqwest upgrade brokenness in benches 2020-02-21 11:58:38 -08:00
Scott Lamb f7da085335 give downloaded .mp4s a useful filename
This is effective both for Chrome's "Save As" dialog and for curl -OJ.
It makes the filename like 20190717135519-driveway-main.mp4 rather than
view.mp4 (Chrome) or view.mp4?s=33-36&ts=true (Curl).
2020-02-21 11:25:12 -08:00
Scott Lamb dd3c3f2f84 update some deps, including cursive
cursive renamed a few methods, so keep up with that. No functional
changes.
2020-01-21 08:58:11 -08:00
Scott Lamb 038fc574e9 upgrade some deps, including reqwest
The reqwest one is particularly notable because it means not having two
versions of hyper/http/tokio/futures/bytes. It also drops a number of
transitive deps; with some work I think I could stop depending on regex
now.
2020-01-09 20:06:30 -08:00
Scott Lamb 73f7cdd261 use application/json for login and logout 2020-01-09 16:24:03 -08:00
Scott Lamb 8af7bca6c2 upgrade to hyper 0.13 ecosystem
This doesn't take much advantage of async fns so far. For example, the
with_{form,json}_body functions are still designed to be used with
future combinators when it'd be more natural to call them from async
fns now. But it's a start.

Similarly, this still uses the old version of reqwest. Small steps.

Requires Rust 1.40 now. (1.39 is a requirement of async, and 1.40 is a
requirement of http-serve 0.2.0.)
2020-01-09 16:07:46 -08:00
Scott Lamb fce0c5b014 use a released version of nix 2019-12-30 07:46:53 -06:00
Scott Lamb 79351eb84c run CI on bionic, not xenial
xenial is too old for 6fb346c to work. From comparing release dates, I
think it's reasonable to guess people won't have trouble running
something newer. In particular, there have been two major Raspbian
releases since then, so current Pi systems will be more bionic-like than
xenial-like.

https://wiki.ubuntu.com/Releases
* xenial (LTS) was relesed 2016-04-21
* bionic (LTS) was released 2018-04-26

https://en.wikipedia.org/wiki/Raspbian
* stretch was released 2017-08-17
* buster was released 2019-06-24

https://www.debian.org/releases/
* stretch was released 2017-06-17
* buster was released 2019-07-06
  (interesting that Raspbian buster was released before Debian buster)
2019-12-30 06:51:01 -06:00
Scott Lamb 6fb346cc8b address AVStream::codec deprecation
The codec -> codecpar move was sufficiently long ago (libavformat
57.5.0 on 2016-04-11) that I think we can just get away with requiring
the new version. Let's try it.

But if someone complains, AVCodecParameters and AVCodecContext look
sufficiently similar we could probably just use one or the other based on
the version we're compiling with.
2019-12-29 08:35:39 -06:00
Scott Lamb 7179ea04e3 address av_lockmgr_register deprecation 2019-12-29 08:20:25 -06:00
Scott Lamb 2ab7dbc9fb stop using deprecated try! 2019-12-28 08:07:33 -06:00
Scott Lamb e8a00d4639 use parking_lot::Once in ffmpeg
I'm getting deprecation warnings for std::sync::ONCE_INIT, and I'm
not sure when std::sync::Once::new() became a const fn. Just as easy to
switch to parking_lot.
2019-12-28 08:03:05 -06:00
Scott Lamb 154d0c30c0 note caveat on signals schema 2019-12-28 08:00:38 -06:00
Scott Lamb 72d301af6e get rid of deprecated mem::uninitialized()
This requires a Rust version bump, as MaybeUninit was introduced in Rust
1.36.
2019-12-28 07:51:47 -06:00
Scott Lamb 2bd8963961 garbage collection for signals 2019-12-28 07:48:08 -06:00
Scott Lamb 1fdf6eb022 better logging for ffmpeg errors 2019-09-26 16:10:13 -07:00
Scott Lamb 0a29f62fd3 better logs during normal operation
* don't log every time we delete stuff; leave it for the flush
* when flushing, break apart counts by sample file dir and include
  human-readable sizes
2019-09-26 16:09:58 -07:00
Scott Lamb 54e06a5326 clean up old garbage files on v5 upgrade 2019-07-24 22:18:44 -07:00
Scott Lamb fe575e1b63 stop using sync::ONCE_INIT
This addressed a deprecation warning on nightly (will be in Rust 1.38).
Use parking_lot instead, which in theory is faster (although I doubt
it's significant here).
2019-07-24 21:52:55 -07:00
Scott Lamb 433be217ac improve test of upgrade from v0 on up; fix bugs
Now the test actually has a recording and garbage with matching files.
This caught a few problems in the upgrade procedure:

* it didn't work with foreign keys enabled because the new recording
  table was set up after the new camera table, and the old recording
  table was destroyed after the old camera table. And now I enable
  foreign keys all the time. Reorder the procedure to fix.

* the pathname manipulation in the v2 to v3 procedure was incorrect
  since my introduction of nix because I gave it a &[u8] with the
  trailing nul, where I should have used CStr::from_bytes_with_nul.

* it wasn't removing garbage files. It'd be most natural to do this
  in the v2 to v3 upgrade (with the rename) but I historically removed
  the table when upgrading to v2. I can't redefine the schema now, so
  do it unnaturally.

  I'm considering also renaming all uuid-like files on upgrade to v4/v5
  to clean up this mess automatically for installations that have
  already done this upgrade.
2019-07-21 22:49:50 -07:00
Scott Lamb 01d20960ef improve error messages on unparseable text protos
Takes advantage of stepancheg/rust-protobuf#428
2019-07-20 16:22:24 -07:00
Scott Lamb 79ac89dc7c use the nix repository again
nix-rust/nix#1097 is merged so it does what we need now.
2019-07-20 16:13:12 -07:00
Scott Lamb 81ae879ac6 mount options for fewer write operations 2019-07-20 15:33:51 -07:00
Scott Lamb 2ead8f8332 keep frame poiners in release mode
This makes it easier to get call graphs with perf.
2019-07-20 15:33:12 -07:00
Scott Lamb 18c693fa46 update deps
The immediate motivation is that Cargo.lock referred to a commit version
in a PR branch of my nix fork that no longer exists. (I didn't know, but
it makes sense, that "git push -f" not only forcibly updates the branch
to refer to a new commit but also gets rid of orphaned commits.) Use a
moonfire branch that I'll keep stable until I'm ready to move on.

I also updated parking_lot and rusqlite to new major versions (nothing
in the interface that I care about has changed) and did a full cargo
update.
2019-07-17 14:32:09 -07:00
Scott Lamb e52e725958 s/std::fs::read_dir/nix::dir::Dir/ in a few spots
This is nicer in a few ways:

   * I can use openat so there's no possibility of any kind of a race
     involving scanning a different directory than the one used in
     other ways (locking, metadata file, adding/removing sample files)
   * filename() doesn't need to allocate memory, so it's a bit more
     efficient
   * dogfooding - I wrote nix::dir.
2019-07-12 11:07:14 -07:00
Scott Lamb bb227491b6 use nix to remove many uses of unsafe 2019-07-11 21:59:01 -07:00
Scott Lamb d75157af56 fix d7a918d regression in SQLite required version
The pragma_* table-valued-functions require SQLite 3.16.0 (2017-01-02).
2019-07-11 14:00:09 -07:00
Scott Lamb d7a918d397 schema comparison in new upgrade tests, "moonfire-nvr check"
The .sql files here are copied from earlier revisions:

v0.sql  fee4141:src/schema.sql
v1.sql  0d69f4f:src/schema.sql
v3.sql  422cd2a:db/schema.sql
2019-07-11 13:31:33 -07:00
Scott Lamb f1112031c2 Merge branch 'master' into new-schema 2019-07-10 17:03:30 -07:00
Scott Lamb 856c01918b Update test to allow ffmpeg 4.x edit list behavior
Fixes #10
2019-07-10 17:02:45 -07:00
Scott Lamb d2e18ca5e2 improve `flush_if_sec` docs 2019-07-10 15:17:55 -07:00
Scott Lamb fb50617a7b add links to the wiki 2019-07-10 11:45:25 -07:00
Scott Lamb 34253fb96a add links to the wiki 2019-07-10 11:43:58 -07:00
Scott Lamb 106cf8cb4b Merge branch 'master' into new-schema 2019-07-10 02:03:13 -07:00
Scott Lamb 81d4fd67d4 suggest RequireMountsFor in systemd service file
Besides using one line instead of two, this avoids the need to do hex
escaping of characters like hyphens.
2019-07-10 02:00:10 -07:00
Scott Lamb 8159acf703 Merge branch 'master' into new-schema 2019-07-10 01:11:25 -07:00
Scott Lamb f80c99a43f set sqlite3 options for full durability 2019-07-10 01:09:52 -07:00