Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicast, improvements, bug fixes #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

RandDruid
Copy link

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. so far tested on only one device - TRUEN HD encoder
  2. Transport Protocol may be selected based on device capabilities (AUTO option?)

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:
0) Unit tests update (if needed?)
1) so far tested on only one device - TRUEN HD encoder
2) Transport Protocol may be selected based on device capabilities (AUTO option?)
Contained in no branch
Contained in no tag

Derives from tag: 1.1 + 52 commits
@RandDruid
Copy link
Author

RandDruid commented Oct 21, 2019

Test on different PC and two different video encoders. Found small problem with IPv6 addresses, but already fixed it in third commit.
But in general works like a charm.
In a dump below PC .244 opens and closes two sessions to .13 and .14. Encoders multicast to 224.10.0.0 and 239.127.0.14 respectively. RTP & H264 packets are hidden.
dump_2streams

@RandDruid RandDruid mentioned this pull request Oct 23, 2019
Revan1985 pushed a commit to Revan1985/RtspClientSharp that referenced this pull request Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant