scottlamb / moonfire-nvr

Moonfire NVR, a security camera network video recorder
Other
1.19k stars 138 forks source link

Unable to connect TP-LINK IP Camera #238

Closed hanyuwei70 closed 1 year ago

hanyuwei70 commented 1 year ago

Describe the bug Unable to parse onvif data.

To Reproduce connect to this IPC.

Expected behavior it will connect to stream normally

Server (please complete the following information): Running scottlamb/moonfire-nvr:v0.7.5 log

 W20220906 23:37:42.542 s-c1-main moonfire_nvr::streamer] c1-main: sleeping for PT1S after error: [192.168.2.2:52892(me)->192.168.2.29:554@2022-09-06T23:37:42, 0@2022-09-06T23:37:42] Ok response to DESCRIBE CSeq=1: Unable to parse stream 2: invalid RTP payload type "smart/1/90000"
raw SDP: "v=0\r
o=- 14665860 31787219 1 IN IP4 192.168.2.29\r
s=Session streamed by "TP-LINK RTSP Server"\r
t=0 0\r
m=video 0 RTP/AVP 96\r
c=IN IP4 0.0.0.0\r
b=AS:4096\r
a=range:npt=0-\r
a=control:track1\r
a=rtpmap:96 H265/90000\r
a=fmtp:96 profile-space=0;profile-id=1;tier-flag=0;level-id=150;interop-constraints=000000000000;sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAlqwJ;sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAlqABQCAFof4qtO6JLuaAgA27oADN/mAE;sprop-pps=RAHAcvAbJA==\r
m=audio 0 RTP/AVP 8\r
a=rtpmap:8 PCMA/8000\r
a=control:track2\r
m=application/TP-LINK 0 RTP/AVP smart/1/90000\r
a=rtpmap:95 TP-LINK/90000\r
a=control:track3\r
"
Backtrace:
   0: failure::backtrace::internal::InternalBacktrace::new
             at .cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/internal.rs:46:44
   1: failure::backtrace::Backtrace::new
             at .cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/mod.rs:121:35
      <failure::backtrace::Backtrace as core::default::Default>::default
             at .cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/mod.rs:140:13
   2: <failure::error::error_impl::ErrorImpl as core::convert::From<F>>::from
             at .cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/error_impl.rs:19:17
   3: <failure::error::Error as core::convert::From<F>>::from
             at .cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/mod.rs:36:18
      <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:2064:27
      moonfire_nvr::stream::RetinaStreamInner::play::{{closure}}
             at src/server/src/stream.rs:116:27
   4: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19
      <tokio::time::timeout::Timeout<T> as core::future::future::Future>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/time/timeout.rs:176:33
   5: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:161:17
      tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/loom/std/unsafe_cell.rs:14:9
      tokio::runtime::task::core::CoreStage<T>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:151:13
      tokio::runtime::task::harness::poll_future::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:467:19
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panic/unwind_safe.rs:271:9
   6: std::panicking::try::do_call
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
      tokio::runtime::task::harness::poll_future
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:455:18
   7: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:103:27
      tokio::runtime::task::harness::Harness<T,S>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:57:15
   8: tokio::runtime::task::raw::RawTask::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:80:18
      tokio::runtime::task::LocalNotified<S>::run
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/mod.rs:347:9
      tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:425:13
      tokio::coop::with_budget::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:102:9
      std::thread::local::LocalKey<T>::try_with
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:413:16
      std::thread::local::LocalKey<T>::with
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:389:9
   9: tokio::coop::with_budget
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:95:5
      tokio::coop::budget
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:72:5
      tokio::runtime::thread_pool::worker::Context::run_task
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:424:9
  10: tokio::runtime::thread_pool::worker::Context::run
  11: tokio::runtime::thread_pool::worker::run::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:376:17
      tokio::macros::scoped_tls::ScopedKey<T>::set
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/macros/scoped_tls.rs:61:9
  12: tokio::runtime::thread_pool::worker::run
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:373:5
  13: tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/worker.rs:352:45
      <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/task.rs:42:21
  14: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:161:17
      tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/loom/std/unsafe_cell.rs:14:9
      tokio::runtime::task::core::CoreStage<T>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/core.rs:151:13
      tokio::runtime::task::harness::poll_future::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:467:19
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
      tokio::runtime::task::harness::poll_future
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:455:18
      tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:103:27
      tokio::runtime::task::harness::Harness<T,S>::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/harness.rs:57:15
  15: tokio::runtime::task::raw::RawTask::poll
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/raw.rs:80:18
      tokio::runtime::task::UnownedTask<S>::run
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/task/mod.rs:384:9
      tokio::runtime::blocking::pool::Task::run
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:91:9
      tokio::runtime::blocking::pool::Inner::run
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:308:17
  16: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at .cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/blocking/pool.rs:288:17
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys_common/backtrace.rs:122:18
  17: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/mod.rs:498:17
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panic/unwind_safe.rs:271:9
      std::panicking::try::do_call
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:492:40
      std::panicking::try
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:456:19
      std::panic::catch_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panic.rs:137:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/mod.rs:497:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
  18: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys/unix/thread.rs:108:17
  19: start_thread
  20: clone

Camera (please complete the following information): TP-LINK TL-IPC44AW-COLOR 4.0 FW: 1.0.10 Build 220330 Rel.35741n

Desktop (please complete the following information): Unrelated

scottlamb commented 1 year ago

It's stumbling over this third stream description:

m=application/TP-LINK 0 RTP/AVP smart/1/90000\r
a=rtpmap:95 TP-LINK/90000\r
a=control:track3\r

which doesn't follow the rules of RFC 8866 section 5.14. In particular, the smart/1/90000 makes no sense. The RFC says:

 m=<media> <port> <proto> <fmt> ...

 If the <proto> subfield is RTP/AVP or RTP/SAVP, the <fmt>
 subfields contain RTP payload type numbers.

It should probably be 95 as described by the following line.

The application/TP-LINK also probably should be just application; this is supposed to be just the type not the subtype, and there are only a few values defined in the registry.

It looks like ffmpeg ignores this stream because the media type application/TP-LINK isn't one of ffmpeg's few understood/allowed ones (video, audio, application, text). I can change Retina (Moonfire's RTSP library) to also ignore this stream based on the media type and/or the parsing problem, rather than producing an error.

I have no idea what information is contained in this stream. application/TP-LINK doesn't tell me anything. Not video or audio anyway.

hanyuwei70 commented 1 year ago

Thanks for your time investigating this issue. Maybe it's TP-LINK's private usage for motion detection? you can safely ignore it (or produce a warning).