Fixed the issue when reconstructing h264 frames that are not continuous #221
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.
Hello, I noticed that there is an issue with RTP frame handling (h264), when receiving a stream with a noticeable packet loss. The crash happens in the following case. Consider the client receiving these RTP frames:
In that case the packet seq 102 was lost. When the library receives seq 104, then it can successfully reconstruct the NAL unit from seq 103, 104 and deallocate them. Then the library receives seq 106 and incorrectly determines the frames 100-106 as continuous and attempts to reconstruct the NAL unit from them -> resulting in a crash when accessing deallocated 103 frame.
![Screenshot 2024-06-03 at 10 24 15](https://private-user-images.githubusercontent.com/17294609/335999807-52817a48-c9e8-4b62-8bc0-6d0e49545633.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MzkxNTMsIm5iZiI6MTczOTkzODg1MywicGF0aCI6Ii8xNzI5NDYwOS8zMzU5OTk4MDctNTI4MTdhNDgtYzllOC00YjYyLThiYzAtNmQwZTQ5NTQ1NjMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDA0MjA1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdiZGE4MjdiNTIwMDNiN2M2Mzc4ZmI1YjA0YzU2MTQ2OTVjMDVkZTExYjE5NGNhZThmY2ExYzM5ZDhjMjgxOWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.vfPJcYAcuHKY9Juskm-MoOttUnoGeyg1tnltOxFIiVM)
Looks like the issue is that
continuous
flag was never reset to false in case the frames are not continuous.Example of the crash:
![Screenshot 2024-06-03 at 10 22 39](https://private-user-images.githubusercontent.com/17294609/335999676-3b84a896-6ace-4b0b-8ab1-98bc6813ccdf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MzkxNTMsIm5iZiI6MTczOTkzODg1MywicGF0aCI6Ii8xNzI5NDYwOS8zMzU5OTk2NzYtM2I4NGE4OTYtNmFjZS00YjBiLThhYjEtOThiYzY4MTNjY2RmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDA0MjA1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNkYWQwZTZkNjg3MDRiZmZkNDA3NTQyNDBlZDMzZDFiNzM2YThjNmQ4ZjdkZTQ0OTRkMjcwZmJkZjc0YTZkYmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ri80XIirKqEzoNu1FkcgYYecnsDteEoZeAMlSDJBxsY)