Commit Graph

149 Commits

Author SHA1 Message Date
Scott Lamb
307a3884a0 drop ffmpeg support
* switch the config interface over to use Retina and make the test
  button honor rtsp_transport = udp.

* adjust the threading model of the Retina streaming code.

  Before, it spawned a background future that read from the runtime and
  wrote to a channel. Other calls read from this channel.

  After, it does work directly from within the block_on calls (no
  channels).

  The immediate motivation was that the config interface didn't have
  another runtime handy. And passing in a current thread runtime
  deadlocked. I later learned this is a difference between
  Runtime::block_on and Handle::block_on. The former will drive IO and
  timers; the latter will not.

  But this is also more efficient to avoid so many thread hand-offs.
  Both the context switches and the extra spinning that
  tokio appears to do as mentioned here:
  https://github.com/scottlamb/retina/issues/5#issuecomment-871971550

  This may not be the final word on the threading model. Eventually
  I may not have per-stream writing threads at all. But I think it will
  be easier to look at this after getting rid of the separate
  `moonfire-nvr config` subcommand in favor of a web interface.

* in tests, read `.mp4` files via the `mp4` crate rather than ffmpeg.
  The annoying part is that this doesn't parse edit lists; oh well.

* simplify the `Opener` interface. Formerly, it'd take either a RTSP
  URL or a path to a `.mp4` file, and they'd share some code because
  they both sometimes used ffmpeg. Now, they're totally different
  libraries (`retina` vs `mp4`). Pull the latter out to a `testutil`
  module with a different interface that exposes more of the `mp4`
  stuff. Now `Opener` is just for RTSP.

* simplify the h264 module. It had a lot of logic to deal with Annex B.
  Retina doesn't use this encoding.

Fixes #36
Fixes #126
2022-03-18 13:22:47 -07:00
Scott Lamb
be3a5b200e prepare v0.7.2 2022-03-16 18:31:12 -07:00
Scott Lamb
319d7c3e1d move perms to proper spot in config 2022-03-16 18:31:07 -07:00
Scott Lamb
f4d5784176 fix config file syntax in guide (#133) 2022-03-16 15:43:23 -07:00
Scott Lamb
f18b58613c improve the guide's docker script
This addresses the `"docker run" requires at least 1 argument.` error
described in #205 and clarifies some comments.
2022-03-16 12:47:00 -07:00
Scott Lamb
ae8fbaff83 add screenshot for selecting guide ver 2022-03-16 12:35:57 -07:00
Scott Lamb
892427592e tweak config format (#133)
* switch from json to toml.
  I think this will be more user-friendly. It allows comments and has
  less punctuation. Fewer surprises than yaml (which has e.g. the
  "Norway problem"). I might have stayed with JSON if I could see a
  good serde json library that allows comments, but hson is unmaintained
  and serde-json strictly follows the spec.

* switch from camelCase to snake_case. Seems more idiomatic for TOML
  and matches the Rust source.

* forbid unknown keys. Better to spot errors sooner.

* rename "trust_forward_hdrs" to "trust_forward_headers". Nothing else
  is abbreviated.
2022-03-16 12:34:39 -07:00
Scott Lamb
de28f6eed3 point to correct version of install instructions
This is particularly important right now. The master branch describes
a config file that doesn't exist in the latest release (0.7.1).

Fixes #204
2022-03-11 15:38:52 -08:00
Scott Lamb
0a9ec04a4e install instructions updates
Fixes #204

* The docker container won't start if a bind refers to a path that
  doesn't exist yet, so move the /etc/moonfire-nvr.json creation up
* Remove redundant command in the dedicated hard drive setup, and
  improve its clarity
2022-03-11 15:02:29 -08:00
Scott Lamb
7467b382dc make Unix sockets bind reliably and add to config 2022-03-11 11:52:00 -08:00
Scott Lamb
ceaef46ea9 introduce /etc/moonfire-nvr.json (#133) 2022-03-09 13:18:33 -08:00
Scott Lamb
9d70d68710 fix #187 via a dependency upgrade
I did a full `cargo upgrade` and fixed what it broke:

*   a couple things for the latest protobuf 3.0 alphas
    (note alphas don't promise API stability)
*   new minimum supported Rust version

This should have some other nice effects: parking_lot now uses inline
assembler, tokio has gotten faster, etc.
2022-03-08 11:24:44 -08:00
John Poole
09e57462dc Update build.md
Scott revised the directory path some time ago, the correct path the release build was not updated until this change.
2021-11-23 10:25:19 -08:00
Scott Lamb
44b1ac965d bump minimum Rust to 1.53
1c9a556 started depending on arrays implementing IntoIterator. I keep
forgetting that 1.52 doesn't support this. There's really no compelling
reason to keep building on 1.52, so don't.
2021-10-27 14:55:04 -07:00
Scott Lamb
981cee0706 revert cursive upgrade
SelectView::set_selection doesn't seem to be working properly. The
symptom is editing an existing camera will clear the sample file dir,
and thus hitting edit without making any changes will fail.
2021-10-27 14:27:10 -07:00
Scott Lamb
ddda01e4fa preparing v0.7.0 2021-10-26 18:54:26 -07:00
Scott Lamb
985f6e675f prepare v0.6.7 w/ Retina v0.3.3
This improves authentication over RTSP.
2021-10-20 14:59:33 -07:00
John Poole
19a9324649 Update build.md
change directory step between server and ui builds.
2021-09-29 20:32:17 -07:00
Scott Lamb
0c0c0692f3 prepare version 0.6.6 2021-09-23 20:02:31 -07:00
Scott Lamb
b41a6c43da shutdown better
After a frustrating search for a suitable channel to use for shutdown
(tokio::sync::Receiver and
futures::future::Shared<tokio::sync::oneshot::Receiver> didn't look
quite right) in which I rethought my life decisions, I finally just made
my own (server/base/shutdown.rs). We can easily poll it or wait for it
in async or sync contexts. Most importantly, it's convenient; not that
it really matters here, but it's also efficient.

We now do a slightly better job of propagating a "graceful" shutdown
signal, and this channel will give us tools to improve it over time.

* Shut down even when writer or syncer operations are stuck. Fixes #117
* Not done yet: streamers should instantly shut down without waiting for
  a connection attempt or frame or something. I'll probably
  implement that when removing --rtsp-library=ffmpeg. The code should be
  cleaner then.
* Not done yet: fix a couple places that sleep for up to a second when
  they could shut down immediately. I just need to do the plumbing for
  mock clocks to work.

I also implemented an immediate shutdown mode, activated by a second
signal. I think this will mitigate the streamer wait situation.
2021-09-23 16:33:29 -07:00
John Poole
156d3dde9d Update build.md
See Issue #163
2021-09-16 16:18:56 -07:00
Scott Lamb
3de605be6c improve some log msgs' readability 2021-08-31 08:59:33 -07:00
Scott Lamb
7ed02bd112 improve install guide wording (see #151) 2021-08-26 09:49:43 -07:00
Scott Lamb
30cea5cfcb several documentation improvements
*   prefix docker/nvr commands with sudo (fixes #142).
    I was just going to link to the docker documentation on setting
    up non-root access, but that's kind of a personal preference.
    I included a `<details>` about it instead and made all the commands
    work with sudo.

*   take better advantage of github markdown's code block syntax
    highlighting. Use "console" for shell session stuff, put the
    "nvr" wrapper script in its own block with "bash".

*   add some comments to nvr wrapper script where people need to
    make changes and/or will be confused.

*   add a `<details>` that talks about shutting down and restarting
    the session around `nvr config` (see #151). Still not user-friendly
    but at least it's better documented now.
2021-08-23 12:44:48 -07:00
Scott Lamb
826b81a95c further refine UI install cmd (#150)
* add the command to create `/usr/local/lib/moonfire-nvr`, necessary
  the first time
* have the files owned by root and use world-readable permissions, even
  if the building user has a restrictive umask set
2021-08-19 21:54:58 -07:00
Scott Lamb
7518b4c865 correctly describe installation in build guide
There were several incorrect/out-of-date paths here, and it didn't
have example commands to install the server or UI.

Fixes #150
2021-08-19 21:43:16 -07:00
Scott Lamb
6270cc0ee4 adjust minimum SQLite version
"without rowid" was introduced in 3.8.2, not 3.14.0. The latter
was just "without rowid" virtual tables, a more obscure feature.
2021-08-19 10:59:38 -07:00
Scott Lamb
a574b51e26 caution against distro Rust pkgs (#109) 2021-08-19 10:37:02 -07:00
Scott Lamb
4e77a26410 document and check minimum SQLite version
Fixes #147
2021-08-19 10:08:53 -07:00
Scott Lamb
4204d84bde
disable proxy buffering in nginx
Buffering to local disk is unnecessary and wasteful.
Moonfire connections are cheap.
2021-08-13 15:28:31 -07:00
Scott Lamb
b8b5038f71 better error msg on live view when misconfigured
Improves (but doesn't fix) #119 and #120.
2021-08-13 12:02:42 -07:00
Scott Lamb
115b081dcd update arm docker build notes 2021-08-12 09:36:13 -07:00
Scott Lamb
164c8c5b21 clarify support for node 12 and 14
* run node 12, 14, and 16 (next to be supported) on CI. This will catch
  node version-specific problems like that solved in dad9bdc.
* mention 12 and 14 in build instructions and link to instructions for
  installing that version.
* follow this in Dockerfile, installing version 14. This addresses
  a "Cannot find module 'worker_threads'" error introduced in
  39a63e0, which (inadvisedly) upgraded gzipper 4->5 in addition to
  the material-ui upgrade.
* use utf-8 encoding rather than ascii in live part parser. Those
  builds apparently don't support ascii. iThey must use "small-icu" or
  have ICU disabled, as described here:
  https://nodejs.org/api/util.html#util_encodings_supported_when_node_js_is_built_with_the_small_icu_option
2021-08-11 23:45:17 -07:00
Scott Lamb
f4c70803d3 add warning about docker builds not working on arm
see #141
2021-08-11 14:38:41 -07:00
Scott Lamb
889deac5be explicitly cd into dir in build instructions
as suggested in #141
2021-08-11 13:52:53 -07:00
Scott Lamb
84ce447fab
use journald log driver in docker wrapper script
As mentioned in https://lwn.net/Articles/676831/, Docker's default loses the logs every time a container is destroyed. Also, https://docs.docker.com/config/containers/logging/configure/ says that the default never rotates the logfiles.
2021-07-16 09:23:45 -07:00
Scott Lamb
3ce9366b0c links to system setup wiki page 2021-07-13 16:08:50 -07:00
Scott Lamb
2c3a22c223 link to our own guide on disabling UAS 2021-07-13 12:49:17 -07:00
Scott Lamb
6046598179 use "unless-stopped" rather than "on-failure"
The latter doesn't restart the docker container on system startup.
2021-07-13 11:23:41 -07:00
Scott Lamb
1bd05348bf troubleshooting section about incorrect timestamps 2021-07-13 11:18:17 -07:00
Scott Lamb
f078328935 prepare v0.6.4 2021-06-28 20:32:33 -07:00
Scott Lamb
5be69baaa6 switch default RTSP library to retina 2021-06-28 16:38:21 -07:00
Scott Lamb
3a6918f3df raise minimum Rust version to 1.52
as required by Retina
2021-06-07 14:43:26 -07:00
Scott Lamb
23d77693de read sample files from dedicated threads
Reading from the mmap()ed region in the tokio threads could cause
them to stall:

*   That could affect UI serving when there were concurrent
    UI requests (i.e., not just requests that needed the reads in
    question anyway).
*   If there's a faulty disk, it could cause the UI to totally hang.
    Better to not mix disks between threads.
*   Soon, I want to handle RTSP from the tokio threads (#37). Similarly,
    we don't want RTSP streaming to block on operations from unrelated
    disks.

I went with just one thread per disk which I think is sufficient.
But it'd be possible to do a fixed-size pool instead which might improve
latency when some pages are already cached.

I also dropped the memmap dependency. I had to compute the page
alignment anyway to get mremap to work, and Moonfire NVR already is
Unix-specific, so there wasn't much value from the memmap or memmap2
crates.

Fixes #88
2021-06-04 19:50:13 -07:00
Scott Lamb
90dd68ee7c update nginx tutorial link 2021-06-04 09:00:24 -07:00
Scott Lamb
ede1ce3192 mention tools for autodetecting RTSP URLs 2021-04-27 10:59:55 -07:00
Iron Oxidizer
146a27aac7
improved hard drive setup docs (#122)
* Use the standard UUID syntax for /etc/fstab

* Added instruction to create sample directory

* Update install.md

* Change sample ownership instead of perms
2021-04-11 21:15:45 -07:00
Scott Lamb
2936c138c5 various doc improvements
I bumped the minimum Rust version because I'm taking advantage of
the rustdoc linking added in Rust 1.48:
https://blog.rust-lang.org/2020/11/19/Rust-1.48.html#easier-linking-in-rustdoc
2021-04-10 17:34:52 -07:00
Scott Lamb
98d106553a add a quick troubleshooting note about #119 2021-04-09 14:28:20 -07:00
Scott Lamb
7c0a634bed avoid clock problems on some Docker setups
In particular, this was happening out of the box on Raspberry Pi OS Lite
20210304, as reported by ironoxidizer@gmail.com here:
https://groups.google.com/g/moonfire-nvr-users/c/2j9LvfFl2u8/m/tJcNS2WfCQAJ

*   adjust main.rs to make the problem more obvious
*   mention it in the troubleshooting guide
*   sidestep it in the nvr docker wrapper script

also just use --networking=host rather than --publish (avoiding a proxy
process). I'm using Docker to simplify the build and deployment process,
not as a security boundary, so just do the simpler thing.
2021-04-08 22:21:03 -07:00