Commit Graph

588 Commits

Author SHA1 Message Date
Scott Lamb 2fe961f382 improve live camera error handling
*   don't error out on websocket error message. The close message has
    more useful info. (Unfortunately though, for security reasons it
    doesn't give too much to the script on initial connection failure.)
*   restore normal (non-error/waiting) state when switching cameras.
*   prefix all log messages with the camera name
2021-03-31 09:08:34 -07:00
Scott Lamb f34937220d minor error handling improvements
*   When the MediaSource is in error state (or busy, I think),
    endOfStream throws an exception. This prevented the error from being
    properly displayed in the UI. We don't really need to call
    endOfStream, I guess.
*   including an Event in a format string just said [Object object],
    at least on Safari. Use the type instead, which I think is the
    only useful info in the event anyway.
2021-03-30 16:31:13 -07:00
Scott Lamb d7f4b255bf when developing on Safari, strip HttpOnly
This might be necessary in the production/https case too. But try this
first.
2021-03-30 16:25:20 -07:00
Scott Lamb 478323ec62 write fragmented .mp4s that Safari likes
As required for live view (#59) to work on Safari.

Safari has some "interesting" expectations:
*   There must be a non-empty list of compatible brands. The major brand
    is not automatically included. (Looks like ISO/IEC 14496-12 doesn't
    spell out which is correct.)
*   The tfdt box must be before the trun boxes. Moonfire NVR was not
    compliant with ISO/IEC 14496-12:2015 section 8.8.12.1 before.
    Chrome and Firefox didn't care, but Safari does.
*   The mdat must be written with the small format. Safari is not
    implementing the spec properly.

I figured these out by painstakingly comparing Moonfire NVR's output
with gpac's, making it match almost byte-for-byte until it worked, then
backing out changes one at a time to check which were relevant. Ugh!
2021-03-30 16:07:29 -07:00
Scott Lamb f92a23fd74 fix Multiview to work in Safari and Firefox
LiveCamera itself still doesn't work in Safari, but small steps.
2021-03-29 14:51:38 -07:00
Scott Lamb 64cfd6ed44 dockerfile tweaks
Most importantly, in build-ui.bash, fix an extra "&&". This meant
that if the build command fails, it would proceed and cause confusion.
This happened for me: I ran it without the emulation installed. Both
the build-server and deploy stages had problems, but because of the "&&"
the deploy target didn't actually return failure. After I fixed the
emulation problem, there was a bad cached layer.

Also save the build output from the dev stage.
2021-03-27 21:35:44 -07:00
Scott Lamb 1686196cfb shrink display selector controls 2021-03-26 19:43:50 -07:00
Scott Lamb b0b650b6b9 Merge branch 'master' into new-ui 2021-03-26 19:29:22 -07:00
Scott Lamb 2f3e8a8f57 update lexical-core 0.7.4->0.7.5
I hope this will fix the failures on CI:
https://github.com/scottlamb/moonfire-nvr/runs/2199560446?check_suite_focus=true

Looks like this version was made to do so:
https://github.com/rust-lang/rust/issues/81654

The confusing part is that lexical-core 0.7.4 seems to compile fine
on my workstation with nightly-2021-03-25-x86_64-unknown-linux-gnu,
but not on CI with the same version?!? still, this will probably fix it.
2021-03-26 19:07:30 -07:00
Scott Lamb 0236ab8d64 add live stream viewing to React prototype
It's a start. It can display several streams at once, which is nice.
There are lots of opportunities for improvement:

*   it doesn't keep the videos approximately in sync.
*   it accumulates extra buffering, drifting behind live. This is
    particularly noticeable when it's paused and played again; it can
    be several seconds before it jumps to after the break.
*   it always uses the sub stream rather main. I'd prefer it support
    "auto" (use main if the viewport is larger than the sub stream and
    there's sufficient bandwidth), "main", or "sub".
*   it has a kludgy heuristic where it throws away everything buffered 5
    seconds before the current timestamp. It should throw away
    everything before the current GOP instead, but I need to alter the
    API so it can easily know when that is.
*   it can't tell you when a camera connection is down. This needs an
    API change also.
*   it'd be nice to quickly double-click on a stream to view only it,
    then double-click again to go back to the multi-pane view.
*   it doesn't allow you to zoom in on part of the video. This would be
    nice particularly when viewing 4k video streams on small screens.
*   it has only four preconfigured layouts that subdivide a 16x9
    viewport. You have to choose every camera every time. It'd be nice
    to both allow more flexibility and have more memory.

React prototype: #111
live stream: #59
2021-03-26 16:45:47 -07:00
Scott Lamb 2954a56fce send keepalives on live.m4s
Chrome appears to time out at 60 seconds of inactivity otherwise.
I think it's better to keep the stream open, even if the camera is
broken.

The implementation looks awkward, but that might be the state of Rust
async right now.
2021-03-25 23:11:08 -07:00
Scott Lamb f9c46dca89 fix incorrect prev_media_duration_90k calculation
I spotted this by inspection: adding a media time and wall time didn't
look right. I also confirmed the brokenness on my primary NVR:

```
sqlite> .mode column
sqlite> select
   ...>   r1.composite_id,
   ...>   r1.prev_media_duration_90k,
   ...>   r1.wall_duration_90k,
   ...>   r1.media_duration_delta_90k,
   ...>   r2.composite_id,
   ...>   r2.prev_media_duration_90k
   ...> from
   ...>   recording r1 join recording r2 on (r1.composite_id = r2.composite_id - 1)
   ...> where
   ...>   r1.prev_media_duration_90k + r1.wall_duration_90k + r1.media_duration_delta_90k !=
   ...>     r2.prev_media_duration_90k
   ...> limit 5;
4296791095    2232623913716            5398956            154                       4296791096    2232629312672
4296791096    2232629312672            5400016            38                        4296791097    2232634712688
4296791097    2232634712688            5400729            105                       4296791098    2232640113417
4296791098    2232640113417            5399024            80                        4296791099    2232645512441
4296791099    2232645512441            5400770            124                       4296791100    2232650913211
```

In the first row, the second recording's prev_media_duration_90k is the
first's prev_media_duration_90k plus its wall time, not its media time.
2021-03-25 22:09:29 -07:00
Scott Lamb 6fd4f8975b build cleanly with nightly Rust 2021-03-14+
The CI nightly builds had been broken with the following error:

```
error: custom inner attributes are unstable
  --> /home/runner/work/moonfire-nvr/moonfire-nvr/server/target/debug/build/moonfire-db-415ce696a754c614/out/schema.rs:10:4
   |
10 | #![rustfmt::skip]
   |    ^^^^^^^^^^^^^
   |
   = note: `#[deny(soft_unstable)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
```

I'd thought this was by mistake given that #[rustfmt::skip] is still
advertised on rustfmt's github page, but maybe not. Looks like
rust-protobuf's newest version uses
`#![cfg_attr(rustfmt, rustfmt::skip)]` to avoid this error.

Also fix a warning on nightly about an extraneous semicolon.
2021-03-24 08:10:45 -07:00
Scott Lamb abcd650304 present signal days in API requests
I also enforced some invariants in the signals code, fixing a couple
bugs. The signals code is more complex than I'd like, but hopefully
is working now.
2021-03-23 21:07:07 -07:00
Scott Lamb caf65a045b use 90k units for signal days map
I'd once thought about using 1 second resolution for signals and wrote
this map to match that. But I decided to match signals to the timestamps
used elsewhere instead. Match that for the days map also.
2021-03-23 11:33:51 -07:00
Scott Lamb 7fb8cd7c6a day map datastructure for signals
Not yet actually used.
2021-03-23 10:58:07 -07:00
Scott Lamb 3ec60b85a3 extract & generalize calendar day indexes
My main goal is to support creating indexes for signals as well as
recordings. An additional goal is to just shrink db.rs a bit; it's
gotten quite large.
2021-03-23 09:40:52 -07:00
Scott Lamb 2215032a78 make time pickers full width
Now they vertically align with the max video duration.
2021-03-17 11:18:01 -07:00
Scott Lamb 85da157cf4 Revert "use secondary colors in date pickers"
This reverts commit d273a99f83.
This accidentally increased the density by making my global CSS
overrides ineffective. I'm struggling to achieve both, and I'd rather
have my desired sizing.
2021-03-17 11:10:39 -07:00
Scott Lamb 76ef6e58b8 block outline at select label
Looks like material-ui's `<Select variant="outlined">` needs a redundant
label property to make the layout correct.

https://next.material-ui.com/api/outlined-input/#main-content

"The label of the input. It is only used for layout. The actual
labelling is handled by InputLabel. If specified labelWidth is ignored."
2021-03-17 10:24:51 -07:00
Scott Lamb 83369f673a snappier default display options
*   1-hour videos are a bit faster to render server-side and don't
    require so much index data to be transferred before play starts

*   the timestamp tracks might be causing a lot of excess data transfer
    in some cases. They're currently not interleaved by ascending
    timestamp, and I wonder if they should be. Chrome might be pulling
    all the bytes between the current position in the two tracks, which
    can be excessive. I'll have to consider interleaving when I add
    audio anyway. But for now, just make the default UI display
    snappier. Chrome doesn't display the timestamp track anyway, so
    don't let it slow things down.
2021-03-16 22:28:00 -07:00
Scott Lamb d273a99f83 use secondary colors in date pickers 2021-03-16 21:57:55 -07:00
Scott Lamb e272075941 cleanup unnecessary logging & such 2021-03-16 21:13:12 -07:00
Scott Lamb eb8f6f3ae1 make the video modal easier to dismiss 2021-03-16 16:43:24 -07:00
Scott Lamb 731eb8170d use menu button to show/hide selectors
Once I have more than one area of the UI (e.g., adding config, live
video, or a scrub bar prototype), I'll use this for a pull-down menu to
go between them, and maybe add a filter icon to do what this does. But
this works for now and most closely matches the old UI.

I tried to use a Collapse or Slide transition, but I had trouble getting
it to work on both desktop and mobile. In particular, the way I used the
flex wrap to display the selectors on the left/above doesn't seem
compatible with picking an orientation. If I pick the wrong orientation,
the list views won't fill the empty space.
2021-03-16 16:18:29 -07:00
Scott Lamb 4d6a8c98d9 new display options selector 2021-03-16 14:59:37 -07:00
Scott Lamb 1cb6a19a65 improve time range selector usability
* hide the end day selector away when it's not in use.
  It was confusing, especially since it seemed to have
  a purely black circle over the selected date when disabled.
* add a "Time" label to the time selectors. On desktop,
  this isn't entirely necessary because they have clock icons
  and "hh:mm:ss" annotations. But on mobile, they were entirely blank,
  so it was unclear what they were for.
2021-03-16 14:50:42 -07:00
Scott Lamb 7522b37de7 recommend installing eslint vscode plugin 2021-03-15 23:29:34 -07:00
Scott Lamb 93b0db4c28 visual improvements to list UI, tests
In particular there are fewer reflows while loading.
2021-03-15 23:26:23 -07:00
Scott Lamb 1a5e01adef display tweaks, especially for small screens 2021-03-15 11:08:02 -07:00
Scott Lamb 9d0a48ba00 clear response if range goes back to null
I don't think this ever happens, but just in case, it'd be confusing
if the list didn't clear.
2021-03-14 21:44:03 -07:00
Scott Lamb 718a9a5dc8 sort recordings in descending order by time 2021-03-14 16:27:45 -07:00
Scott Lamb fa53a4e2ec recommended extension for vscode 2021-03-14 16:25:31 -07:00
Scott Lamb a13733d434 trim recordings to match the requested range
This matches the default behavior of the old UI. It's not configurable.
I'm not sure anyone ever deliberately unchecked that box.
2021-03-13 22:38:21 -08:00
Scott Lamb 182ed23a06 typo fix: s/firstUncommited/firstUncommitted/
The typo prevented the "@" URL constraint from being correctly added,
so a backend restart could change the video to point somewhere
unintended.
2021-03-13 21:51:59 -08:00
Scott Lamb 56661924ae Merge branch 'master' into new-ui 2021-03-12 14:53:15 -08:00
Scott Lamb 3c057af896 update lnav config to support newer+older styles 2021-03-12 13:40:37 -08:00
Scott Lamb 6f2befec65 release script fixes 2021-03-12 13:33:08 -08:00
Scott Lamb d5320302a3 prepare version 0.6.2 2021-03-12 12:36:20 -08:00
Scott Lamb 54aef17731 small release script fix 2021-03-12 12:29:34 -08:00
Scott Lamb 2d4e7e5878 tweak the docker release flows 2021-03-12 12:21:44 -08:00
Scott Lamb 1458d668d7 tweak color env variable options
As noted in mylog's 2b1085c:
Looks like both the GNU tools' --color argument and cargo's
CARGO_TERM_COLOR expect always/never rather than on/off. Match that.
Might as well understand off/no/false and on/yes/true also.
2021-03-12 09:24:20 -08:00
Scott Lamb 8ced3155e2 docker optimizations, doc improvements 2021-03-11 23:38:58 -08:00
Scott Lamb ba10cc21cc use moonfire-ffmpeg that *really* builds with 1.45
(and moonfire-ffmpeg now has CI enabled to test this itself)
2021-03-11 20:10:18 -08:00
Scott Lamb 71ba9955c2 use moonfire-ffmpeg that builds with Rust 1.45
Fixes this CI failure:
https://github.com/scottlamb/moonfire-nvr/runs/2091884707
2021-03-11 19:21:17 -08:00
Scott Lamb 3c130f4fea update moonfire-ffmpeg
This picks up moonfire-ffmpeg's 4b13378:

support ffmpeg's multi-call log messages

This should fix this annoying log output:

```
W20210310 13:17:09.060 s-garage_west-main moonfire_ffmpeg::rtsp] 0xaf300950: RTP H.264 NAL unit type 29
W20210310 13:17:09.060 s-garage_west-main moonfire_ffmpeg::rtsp] 0xaf300950:  is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
```

so it looks like this instead:

```
W20210310 13:17:09.060 s-garage_west-main moonfire_ffmpeg::rtsp] 0xaf300950: RTP H.264 NAL unit type 29 is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
```
2021-03-11 19:04:44 -08:00
Scott Lamb fd2d959daa update lock for 0.6.2-dev 2021-03-11 15:41:41 -08:00
Scott Lamb 10b2be3d54 changelog, including upcoming 0.6.2 2021-03-10 17:53:29 -08:00
Scott Lamb 984989dc1c small readability improvements to web.rs
I think this has a minor behavior change: permission denied replies
change to HTTP 403 where they were HTTP 401. The new behavior seems
more correct, as these errors can occur when authentication has
succeeded but the session in question is not authorized for the given
operation. The UI currently doesn't care about this distinction.
2021-03-10 16:21:34 -08:00
Scott Lamb e66a88a591 fix invariant violation on pts jump (#112)
Looks like a refactoring in 9d7cdc09 introduced the possibility this
could fail (where before it might produce a silly i32 pts) and forgot
to restore the invariant.
2021-03-10 12:45:32 -08:00