Commit Graph

284 Commits

Author SHA1 Message Date
Scott Lamb 8dc5d64333 make with_recording_playback less monomorphized
This is a minor code size reduction - instead of being monomorphized
into four variants (according to "cargo llvm-lines"), it's now
monomorphized into two. The stripped release binary on macOS is about
8kB smaller (0.15%). Not a huge improvement but better than nothing.

Benchmarks seem unchanged (though they have a lot of variance).
2018-08-24 15:34:42 -07:00
Scott Lamb d7a94956eb deflake writer tests
There was a race condition here because it wasn't waiting for the db
flush to complete. This made write_path_retries sometimes not reflect
the consequence of the flush, causing an assertion failure. I assume it
was also responsible for gc_path_retries timeouts under travis-ci.
2018-08-07 21:58:40 -05:00
Scott Lamb f3127f563a fifth attempt at travis config
typo: it's --jobs=2, not -jobs=2.
2018-08-07 16:01:43 -05:00
Scott Lamb 01e8dab67f fourth attempt at travis config
* upgrade min required rust to 1.21; crossbeam-deque requires the
  ord_max_min feature, apparently stabilized in this version.

* use "make --jobs=2" to build ffmpeg so it goes faster.
  https://docs.travis-ci.com/user/reference/overview/ says there are 2
  cores available.
2018-08-07 15:51:19 -05:00
Scott Lamb 62a1bad8b9 third attempt at travis config
* upgrade minimum required Rust from 1.17 to 1.20; reffers 0.4.2
  apparently uses std::mem::ManuallyDrop, introduced in 1.20

* install ffmpeg from source (requiring sudo access) rather than using
  the ancient one from Ubuntu Trusty to meet the minimum version
  requirements specified in ffmpeg/build.rs.
2018-08-07 15:28:34 -05:00
Scott Lamb a81de3f620 second attempt at travis config
* list apt packages to install
* apparently it's rust 1.17.0, not rust 1.17
2018-05-01 08:38:25 -07:00
Scott Lamb 7bb33522e2 first attempt at a travis config
This just does a build+test. I'll try the install scripts (for #58) in a
following commit.
2018-05-01 08:28:14 -07:00
Scott Lamb 23b221c5ed address setup_db bitrot (#58) 2018-05-01 07:31:38 -07:00
Scott Lamb f2888e2b32 couple fixes to the dialog close button
* add back in button.css (broken with f5aa008)
* remove a redundant .png file-loader which apparently caused the .png
  asset to not load properly (broken with f5aa008)
2018-04-28 06:39:29 -07:00
Scott Lamb a5528e1c02
Merge pull request #56 from scottlamb/pr-merge-new-schema
Merge new-schema branch
2018-04-27 06:52:46 -07:00
Scott Lamb 23fff5917c Merge branch 'new-schema'
The Rust portions of the merge are straightforward, but the Javascript
is not. The new-schema branch is based on my hacky prototype UI; the
master branch is based on Dolf's rewrite. I attempted to match the
new-schema changes in Dolf's new structure.
2018-04-27 06:42:39 -07:00
Scott Lamb 9982c0b080 small adjustments to auth schema
Nothing uses the user and user_session tables yet; I'm trying to
anticipate what auth will need before freezing schema version 3.
2018-04-27 06:24:02 -07:00
Scott Lamb b0071515e0 update deps
I want to use hyper::server::Request::bytes_mut(), so an update is
needed. Update everything at once. Most notably, the http-serve update
starts using the http crate types for some things. (More to come.)
2018-04-06 15:54:52 -07:00
Scott Lamb f720f6acd4 fix timezone fetching on macOS High Sierra 2018-04-06 13:49:18 -07:00
Scott Lamb 97d831e054 move strutil to base crate
I plan to use strutil::hex in db/auth.rs.
2018-03-30 08:54:20 -07:00
Dolf Starreveld f5aa0080bb A little more UI refactor, cleanup, eslint more strict (#54)
* A little more UI refactor, cleanup, eslint more strict

* Split out imports for jQuery components and put them where needed.
* No longer do all of it in application module.
* Prepares better for code splitting.
* Split out video player dialog
* Simplifies jquery-ui dependencies for code splitting
* Simplifies code
* Configure to generate more, but smaller bundles.
* Setup some more strict eslint settings
* Fix css to import rather than require
* Change settings to correctly support tree shaking in production build

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>

* Remove “old” code from TimeFormatter

* Accidentally left behind due to overlapping PRs

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>
2018-03-25 22:18:56 -07:00
Dolf Starreveld eaae640703 Initial docker support (#55)
* Dockerfile which allows full build on ubuntu
* No cross-compile yet
* Fixed build scripts bug found with docker

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>
2018-03-25 21:03:02 -07:00
Scott Lamb 0701121586 a couple refinements to the new user_session table 2018-03-25 07:23:40 -07:00
Scott Lamb 299c0b1802 Merge branch 'master' (early part) into new-schema
Catch the new-schema branch up with everything up to (but not including) the
big UI refactoring. I'll merge that separately.
2018-03-24 22:29:40 -07:00
Scott Lamb e817b22189 remove an obsolete TODO
StreamStateChanger::new already correctly ensures that non-empty streams can't
switch sample file dirs.
2018-03-24 20:54:56 -07:00
Scott Lamb 65e68d3255 update design docs for new-schema branch changes 2018-03-24 20:51:30 -07:00
Scott Lamb 91636d3193 refine flush_if_sec behavior
The new behavior eliminates a couple unpleasant edge cases in which it
would never flush:

* if all recording stops, whatever was unflushed would stay that way
* if every recording attempt produces a 0-duration recording (such as if the
  camera sends only one frame and thus no PTS delta can be calculated),
  the list of recordings to flush would continue to grow
2018-03-23 15:16:43 -07:00
Scott Lamb addeb9d2f6 add a TimerGuard around db locks & ops
I moved the clocks member from LockedDatabase to Database to make this happen,
so the new DatabaseGuard (replacing a direct MutexGuard<LockedDatabase>) can
access it before acquiring the lock.

I also made the type of clock a type parameter of Database (and so several
other things throughout the system). This allowed me to drop the Arc<>, but
more importantly it means that the Clocks trait doesn't need to stay
object-safe. I plan to take advantage of that shortly.
2018-03-23 13:31:23 -07:00
Scott Lamb c0da1ef880 make v1->v3 upgrade work with --features=bundled
--features=bundled enables -DSQLITE_DEFAULT_FOREIGN_KEYS=1, and so some
operations have to be done in the proper order.

* enable foreign key enforcement all the time, so I test this more reliably.
* reorder some parts of the v1->v3 order. foreign key enforcement is
  immediate (rather than deferred) by default. and ensure
  old_recording_playback isn't left with a dangling reference to old_recording
  at the v2 stage. Instead, wait until v3 to delete tables it depends on.
2018-03-22 09:05:40 -07:00
Scott Lamb c46c50af8f fix another upgrade error in dfee66c 2018-03-22 00:08:49 -07:00
Scott Lamb 2ff7ecb6f4 fix upgrade procedure broken in dfee66c 2018-03-22 00:00:39 -07:00
Scott Lamb 1c9f2a4d83 initial schema for user authentication (#26)
This is only the database schema, which I'm adding now in the hopes of
freezing schema version 3. There's no way yet to create users, much less
actually authenticate.
2018-03-21 23:57:45 -07:00
Scott Lamb dfee66c84b support additional recording_integrity timestamps
These are not actually populated by the code yet. I'm trying to get the
v3 schema frozen as soon as possible; actually using the fields can come
later.

Add some explanation of their value in time.md, along with some general
musing on leap seconds, and a correction on the frequency error of my cameras.
2018-03-21 22:32:41 -07:00
Scott Lamb 88051a1188 adjust startup timings again
I forgot to drop the cache before grabbing the numbers earlier today.
2018-03-20 22:37:45 -07:00
Scott Lamb bdf52d743b adjust some timings in schema.md
The new numbers are taken from my odroid setup. In particular, the size check
is noticeably slower than what I'd gathered before, enough to show that it
shouldn't be performed on startup.
2018-03-20 08:46:48 -07:00
Dolf Starreveld 58152e8d94 Major refactoring of UI code, small UI changes. (#48)
* Major refactoring of UI code, small UI changes.

* Single file index.js split up into separate modules
* Modules for handling UI view components
* Modules for handling JSON/Model data
* Modules for support tasks
* Module to encapsulate Moonfire API
* Main application module
* index.js simplified to just activating main app
* Settings file functionality expanded
* UI adds "Time Format" popup to allow changing time representation
* CSS changes/additions to streamline looks
* Recordings loading indicator only appears after 500ms delay, if at all

* Address first set of PR change requests from Scott.

* Add copyright headers to all files (except JSON files)
* Fix bug with entering time values in range pickers
* Fixed an erroneous comment and/or spelling error here and there
* Fixed JSDoc comments where [description] was not filled in
* Removed a TODO from NVRApplication as it no longer applies
* Fixed bug handling "infinite" case of video segment lengths
* Fixed bug in "trim" handler and trim execution

* Retrofit video continues loading from separate PR

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>

* Address PR comments

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>

* Address PR comments

Signed-off-by: Dolf Starreveld <dolf@starreveld.com>
2018-03-20 07:03:12 -07:00
Scott Lamb caac324bd5 remove moonfire.sublime-workspace
10e736d added this, looks like mistakenly. This file has machine-specific
paths in it, and PR #48 adds it to .gitignore.
2018-03-18 20:59:32 -07:00
Scott Lamb 320374c6e9 favicon: security camera in orange/red circle
This is derived from the following icon:
https://thenounproject.com/term/security-camera/72530
by iconsmind.com. I paid for the royalty-free license.

Fixes #50.
2018-03-12 22:47:44 -07:00
Scott Lamb 0e365a23e1
Merge pull request #52 from dolfs/pr-fix-video-close
Fix bug where video stream continued fetching on player close.
2018-03-12 21:34:47 -07:00
Dolf Starreveld 10e736dd63 Fix bug where video stream continued fetching on player close. 2018-03-12 21:11:27 -07:00
Scott Lamb 4c8daa6d24 save timestamps along with opens 2018-03-10 16:15:36 -08:00
Scott Lamb 5854b31b76 serve .map files as Javascript
This fixes #47 for now at least.
2018-03-10 16:04:37 -08:00
Scott Lamb f81d699c8c new recording_integrity table
A couple rarely-used fields move to here, and I expect I'll add more.
Redo the check command to just put everything in RAM for simplicity.
2018-03-09 13:37:30 -08:00
Scott Lamb 03809eee8e clean up leftover throwaway logging 2018-03-09 10:46:34 -08:00
Scott Lamb 84ce24b7f6
Merge pull request #24 from dolfs/pr-ui-dev-2
Settings can now be taken from separate file with local override.
2018-03-08 21:59:49 -08:00
Dolf Starreveld 353a860146 Normalize case of "Moonfire" 2018-03-08 21:52:15 -08:00
Dolf Starreveld 5727adf3df Settings can now be taken from separate file with local override.
* Various settings in settings-nvr.js module
* settings-nvr-local.js can override settings-nvr.js
* settings-nvr-local is unchecked file
* Both files can be straight maps, or functions returning maps
* webpack env and args available to those functions
2018-03-08 18:26:41 -08:00
Scott Lamb 678fb54b21 delete stale webpack.config.js
This was obsoleted by #22 / a03b986 but mistakenly not deleted.
2018-03-08 02:42:30 -08:00
Dolf Starreveld 8a0bc4c401 Change to allow formatTime to accept a format string. (#23)
* Default format string causes it to work as before
* New FFFF format supported for fractional second in 90k units
2018-03-08 02:41:13 -08:00
Dolf Starreveld a03b98631a Changes to allow active development of UI using webpack and hotloading. (#22)
* Changes to allow active development of UI using webpack and hotloading.

* Update to webpack 4 (will make this work)
* Update webpack.config.js accordingly
* Move webpack.config.js to its own directory
* Split webpack.config.js into base.config.js, dev.config.js and prod.config.js
* Update configs to be "right" for development vs production using --mode

* Want configuration through (optional) local file that is not
  checked in

* Updated package.json for newer babel-loader

* Put in a proxy to localhost port 8080 for evelopment server.

This allows "yarn start" to work on the machine where MoonFire's
server is running. This would be the default situation. Users in
a different setup can change the proxy settings.
2018-03-07 17:34:08 -08:00
Scott Lamb d6fa470713 tests and fixes for Writer and Syncer
* separate these out into a new file, writer.rs, as dir.rs was getting
  unwieldy.
* extract traits for the parts of SampleFileDir and std::fs::File they needed;
  set up mock implementations.
* move clock.rs to a new base crate to be accessible from the db crate.
* add tests that exercise all the retry paths.
* bugfix: account for the new recording's bytes when calculating how much to
  delete.
* bugfix: when retrying an unlink failure in collect_garbage, we shouldn't
  warn about all the recordings no longer existing. Do this by retrying each
  step rather than the whole procedure again.
* avoid double-panic scenarios, which I hit while tweaking the mocks. These
  are quite annoying to debug as Rust doesn't print information about either
  panic. I ended up using lldb to get a backtrace. Better to be cautious about
  what we're doing when already panicking.
* give more context on raw::insert_recording errors, which I hit as well while
  tweaking the new tests.
2018-03-07 04:42:46 -08:00
Dolf Starreveld e4cc8d6c0f Install and build script enhancements (#21)
* Install and build script enhancements

* Use functions for all reporting for consistent output
* Update reporting text to be more clear
* Add some additional messages
* Re-check some install prep items also in install script
* Fix a bug where the wrong db directory would be configured to the service

* Satisfy PR requested changes (spelling mostly).
2018-03-07 04:31:51 -08:00
Scott Lamb 672a327ee2
support serving Access-Control-Allow-Origin header (#19)
support serving Access-Control-Allow-Origin header

Closes #17.
2018-03-03 06:43:36 -08:00
Dolf Starreveld 760b8d95fb Rewrite of the installation script and accompanying documentation. (#15)
Rewrite of the installation script and accompanying documentation.
2018-03-03 06:41:15 -08:00
Scott Lamb b78ffc3808 view in-progress recordings!
The time from recorded to viewable was previously 60-120 sec for the first
recording of a RTSP session, 0-60 sec otherwise. Now it's one frame.
2018-03-02 15:40:32 -08:00