BogdanovKirill / RtspClientSharp

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.
MIT License
706 stars 284 forks source link

Multicast, improvements, bug fixes #63

Closed RandDruid closed 4 years ago

RandDruid commented 4 years ago

bug fixes:

  1. SDES packet header - padding flag must be "false". Fixed.
  2. SDES chunk - text length should not include /0. Fixed.
  3. SDES reports were sent to RTP port instead of RTCP. Fixed.
  4. Since Socket.ReceiveAsync do not natively support cancellation, and receive task was waiting for complete of both RTP and RTCP receive, "normal" cancellation never took place. CloseRtspSessionAsync never called because sockets were closed due to CancelTimeout. As a result, TEARDOWN was never sent. I added WithCancellation task extension and now ReadAsync can be canceled immediately without wait for next incoming packet. I modified only UDP part, but extension can be used in other places too.

improvements:

  1. "Receiver Report Goodbye" packet is sent on session close.
  2. UDP sockets are bound to only one interface, which IP is retrieved from already connected RTSP session. This improves security in certain usage scenarios, especially with multicast.

new features:

  1. UDP multicast support. New SETUP request asking for multicast. New socket extension for multicast groups. Implementation logic is similar to FFMPEG "forced multicast" or VLC --rtsp-mcast option.

todo:

  1. Unit tests update (if needed?)
  2. so far tested on only one device - TRUEN HD encoder
  3. Transport Protocol may be selected based on device capabilities (AUTO option?)
RandDruid commented 4 years ago

Unit tests failed, re-open after fix