Commit Graph

198 Commits

Author SHA1 Message Date
Lucas Zanella
dbf4652840 fixed rtp-info missing for some cameras 2021-08-20 16:42:57 -07:00
Lucas Zanella
9a6e418ea3 fixes control URL error 2021-08-20 16:42:57 -07:00
Scott Lamb
915e6b7404 basic client tests with mock server
There's still a lot of untested functionality, but this is a start.
2021-08-20 16:42:19 -07:00
Scott Lamb
76b3a61eb7 mp4 example: fix panic on empty video
```
thread 'main' panicked at 'range start index 1 out of range for slice of length 0', examples/client/mp4.rs:171:44
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::slice::index::slice_start_index_len_fail
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/slice/index.rs:34:5
   3: client::mp4::TrakTracker::write_common_stbl_parts
   4: client::mp4::Mp4Writer<W>::write_audio_trak
   5: client::mp4::run::{{closure}}
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   7: tokio::park:🧵:CachedParkThread::block_on
   8: tokio::runtime::thread_pool::ThreadPool::block_on
   9: tokio::runtime::Runtime::block_on
  10: client::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```
2021-08-20 10:11:53 -07:00
Scott Lamb
6155d4ebcf be more tolerant of incorrect RTP H.264 framing
I'll be optimistic: fixes #13

At least it seems to fix the Reolink case. We'll see about VStarcam.
2021-08-19 15:01:46 -07:00
Scott Lamb
79ca9941bd remove orphaned import 2021-08-19 13:31:24 -07:00
Scott Lamb
3b652bbb65 try to fix CI error
https://github.com/scottlamb/retina/actions/runs/1148367482
2021-08-19 13:19:04 -07:00
Scott Lamb
d29129792e dust off fuzz tests
* make them build again
* reformat
* check those things on CI. probably too expensive to actually run them.
2021-08-19 13:16:16 -07:00
Scott Lamb
782029a1ca log at promised debug, not warn 2021-08-19 13:01:07 -07:00
Scott Lamb
d8aa4c6565 workaround for Reolink spurious data
Fixes #17

I'm accumulating unit testing debt, but I think I'd rather get this
quickly out in the field to test against scenarios I haven't anticipated
than get my unit tests in order for scenarios I have anticiapted.
2021-08-19 13:00:06 -07:00
Scott Lamb
7d2fb0def1 cargo fmt 2021-08-19 11:26:13 -07:00
Scott Lamb
dadbd443a5 add debugging for #13 2021-08-19 11:23:32 -07:00
Scott Lamb
1c468668d8 include seq in rtp packet error description
This is useful (eg for a `rtp.seq == 0x1234` display filter in
Wireshark) and was just omitted by accident.
2021-08-16 13:34:40 -07:00
Scott Lamb
41765007a6 remove rtcp dependency, prep v0.1.0
rtcp recently had an accidental semver break, so this fixes #8.
I also don't like that newer versions depend on several unnecessary
crates including tokio. retina also depends on tokio, but in the future
I want it to be IO library-agnostic.

I'm moving to v0.1.0 so I *can* release versions that claim semver
compatibility. There are still plenty of API changes to make but also
likely upcoming camera compatibility changes that won't break anything.
2021-08-13 11:37:53 -07:00
Scott Lamb
b1db9a9e8b use SET_PARAMETERS for keepalive
This is the method recommended by the ONVIF Streaming Specification
version 21.06 section 5.2.2.2.

I was using GET_PARAMETERS. This matched ffmpeg's behavior if the
OPTIONS shows that GET_PARAMETERS is supported, although I wasn't doing
the initial OPTIONS request.

Apparently the GW Security GW4089IP will simply ignore GET_PARAMETERS,
not even sending a 405 Method Not Allowed response. It supports and
responds to SET_PARAMETERS.
2021-07-11 20:01:59 -07:00
Scott Lamb
0fceb49977 fix test build break on 1.52 2021-07-08 15:42:16 -07:00
Scott Lamb
00359bf540 prepare v0.0.5 2021-07-08 15:20:55 -07:00
Scott Lamb
df47b6fa35 mp4 example: handle initial video param change
I've noticed some (buggy) cameras' out-of-band parameters don't quite
match the initial in-band parameters. Out-of-band parameters aren't
required anyway, and this is progress toward handling in-band only.
2021-07-08 15:19:38 -07:00
Scott Lamb
de6658961b shrink several large datastructures
*   Box the remaining Depacketizer variants. I already boxed the largest
    ones, which are also the most common. Might as well box the others
    and not have so much dead space in the common case...
*   Don't keep around a full codec::Parameters on all codecs. This
    shrinks several depacketizers. I also avoid some awkward
    destructuring.
*   Box VideoFrame::new_parameters, which is populated rarely.

```
sizes changes on 64-bit platforms:
type                               before  after
client::Stream                        512    312
codec::Depacketizer                   224     16
codec::aac::Depacketizer              232    208
codec::g723::Depacketizer             200    104
codec::h264::Depacketizer             560    552
codec::onvif::Depacketizer            216    128
codec::simple_audio::Depacketizer     208    112
codec::CodecItem                      240    160
codec::VideoFrame                     232    152
codec::AudioFrame                     104    104
codec::MessageFrame                   104    104
client::rtp::SenderReport              72     72
```
2021-07-08 14:54:42 -07:00
Scott Lamb
f5b4c5a9b6 copyright notices in new files 2021-07-08 13:11:56 -07:00
Scott Lamb
29c80c6f0e build fix: add missing files 2021-07-08 11:37:03 -07:00
Scott Lamb
e9a5e4e34a overhaul error type
*   stop using deprecated failure crate and its deps

*   more uniformly detailed error messages

*   an enum of the type of error, currently internal-only. I'm not
    confident enough I understand what cases a caller might want to
    distinguish, so I added a comment inviting input instead of
    exposing it now.

*   while I'm at it, separate connection context and message contexts.
    This shrinks some of the data memmoved around in PacketItem and
    CodecItem.
2021-07-08 11:28:07 -07:00
Scott Lamb
265b6b9490 make Demuxed public 2021-06-28 18:12:04 -07:00
Scott Lamb
7f32639608 don't break after keepalive response!
prepare v0.0.4 immediately; v0.0.3 is effectively unusable.

I want to test this properly, but I haven't yet figured out how to set
up good mocks of tokio::Sleep and such. For now just fix the bug.
2021-06-28 15:30:28 -07:00
Scott Lamb
037c501dfb prepare v0.0.3 release 2021-06-28 14:16:13 -07:00
Scott Lamb
48f2c2eb15 directly implement Stream on Session<Playing>
The new implementation has several benefits:

*   it's more correct, in a way that probably doesn't matter now but
    will if we ever send ONVIF backchannel audio. See the removed
    comment about deadlock possibility. Similarly, I realized that if
    packets became readable halfway through flushing a keepalive, the
    keepalive future would be improperly dropped as described at
    the beginning of this blog post:
    https://carllerche.com/2021/06/17/six-ways-to-make-async-rust-easier/

*   we'll be able to make other method calls on the Session while using
    the stream, eg sending audio with ONVIF backchannel

*   it's 8% faster according to the client benchmark.

*   it doesn't pull in the async-stream dependency anymore.

*   we can name the type of the stream, avoiding a Box in some cases.
2021-06-28 13:51:19 -07:00
Scott Lamb
dacbca8c28 speed up interleaved data parsing
This is a 20% improvement on the freshly-added benchmark.
2021-06-28 10:29:27 -07:00
Scott Lamb
4a8b8f2f77 add a more end-to-end benchmark 2021-06-28 10:04:38 -07:00
Scott Lamb
6503398d3f prepare v0.0.2 2021-06-25 16:48:41 -07:00
Scott Lamb
a097d01f62 cargo fmt 2021-06-25 16:42:12 -07:00
Scott Lamb
1279dec0c3 H.264 fixes, testing, packetizer
Fuzz testing found a few bugs in the new H.264 depacketizer.
Also add a H.264 packetizer. Currently it's just used for testing.
2021-06-25 16:39:48 -07:00
Scott Lamb
af7e8a77fb refactor h264 depacketizer
* add a couple tests

* fix #4: put the whole video frame (including multiple NALs) into
  a single Bytes. This is simpler to use and speeds up the
  depacketize/h264_aac_writevideo benchmark. It's also a behavior
  change; now I include non-VUI data such as SPS/PPS/SEI into the
  data. I think this is a better default but it might be worth
  making customizable.
2021-06-24 22:18:39 -07:00
Scott Lamb
4fe885fd6a benchmark tweaks
* add variant which writes video to /dev/null
* (try?) to compile with debug symbols. (it seems to work but
  cargo flamegraph still seems to complain?)
* faster parsing of inline data. I'd like to figure out why this is
  slow with rtsp_types and fix it, but anyway in this benchmark I want
  to just focus on the depacketization
2021-06-24 22:16:13 -07:00
Scott Lamb
ca691d1887 quick benchmark 2021-06-09 23:44:43 -07:00
Scott Lamb
b9aad86d57 box aac and h264 depacketizers
These are huge, not present for every stream, and only allocated once at
describe time, so boxing makes sense. I probably should listen to that
clippy lint!
2021-06-09 22:42:48 -07:00
Scott Lamb
bdc23ae318 add repository link to Cargo.toml 2021-06-09 22:26:52 -07:00
Scott Lamb
45e15d43fd fix README formatting 2021-06-09 15:24:10 -07:00
Scott Lamb
f56b63225d prepare v0.0.1 release 2021-06-09 13:50:30 -07:00
Scott Lamb
cb719cd34d remove redundant decode function 2021-06-07 21:47:31 -07:00
Scott Lamb
70012e300b remove unnecessary parens
(the braces were added by "cargo fmt", making the parens redundant)
2021-06-07 21:36:19 -07:00
Scott Lamb
cd407ce93a add missing copyright header 2021-06-07 21:35:08 -07:00
Scott Lamb
b0575b3794 cargo fmt 2021-06-07 21:32:44 -07:00
Scott Lamb
e9125500b5 bump deps 2021-06-07 21:32:04 -07:00
Scott Lamb
954c181569 use my pr-sps-overflow branch of h264-reader
This makes fuzz testing get a bit farther at least.
2021-06-07 21:30:18 -07:00
Scott Lamb
45147200ce start h.264 fuzz testing 2021-06-07 18:12:45 -07:00
Scott Lamb
1bcc864344 trim dependencies 2021-06-04 21:20:56 -07:00
Scott Lamb
8a40070b8a
Fix typo 2021-06-03 22:35:33 -07:00
Scott Lamb
5cc69e751c initial commit 2021-06-03 16:49:53 -07:00