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

Enhance memory management and reliability in RTSP server #6

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paulomorgado
Copy link

This might look a bit extreme, but the intention is to assure to the caller that the data provided won't be modified by using ReadOnlySequence<byte> instead of List<byte[]> and reduce memory allocated by ITrack implementations.

Changes:

  • Refactored audio and video track handling to utilize ReadOnlySequence<byte> for better performance and memory efficiency.
  • Introduced AdjustedSizeMemoryOwner for effective memory allocation.
  • Updated method signatures for RTP packet creation and sample feeding to accept ReadOnlySequence<byte>, ensuring consistency and optimizing memory usage.
  • Modified RTPPacketUtil to read timestamps from ReadOnlySpan<byte>, enhancing performance.
  • Overall code structure refined for improved readability and memory management.

@paulomorgado paulomorgado marked this pull request as draft January 17, 2025 17:04
- Refactored audio and video track handling to utilize `ReadOnlySequence<byte>` for better performance and memory efficiency.
- Introduced `AdjustedSizeMemoryOwner` for effective memory allocation.
- Updated method signatures for RTP packet creation and sample feeding to accept `ReadOnlySequence<byte>`, ensuring consistency and optimizing memory usage.
- Modified `RTPPacketUtil` to read timestamps from `ReadOnlySpan<byte>`, enhancing performance.
- Overall code structure refined for improved readability and memory management.
@paulomorgado paulomorgado marked this pull request as ready for review January 17, 2025 18:34
@paulomorgado paulomorgado marked this pull request as draft January 18, 2025 19:55
@jimm98y
Copy link
Owner

jimm98y commented Jan 19, 2025

When it comes to SharpOnvifServer library changes, the only concern I have regarding these new APIs is the netstandard2.0 (in)compatibility. It might require using a polyfill such as https://github.com/[meziantou/Meziantou.Polyfill](https://github.com/meziantou/Meziantou.Polyfill) - this should be the same one SharpRTSP is already using, so it will not introduce any additional dependency if possible.

@paulomorgado
Copy link
Author

Making these changes helps me understand the library. 😄

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.

2 participants