[core] Refactoring: added packUniqueData(..) function #2229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code related to forming an original data packet for sending has been moved to a separate function
packUniqueData(..)
.The encryption of the payload has been moved inside that function as well, as it is only needed to encrypt the original payload. Once encrypted, it is stored so in the sender buffer, thus the second encryption call is needed when the packet is being retransmitted.
Moving the encryption inside the
packUniqueData(..)
also means that packet timestamp and destination socket ID are not yet set in the header of the packet. However, only the packet sequence number is used as the counter for the AES encryption, therefore this change is safe.Changes extracted from PR #2180.
Tests
Checked encryption and decryption including KM refresh using
srt-xtransmit
: