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

fix: reassemble RTP fragments #503

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

swoga
Copy link
Contributor

@swoga swoga commented Oct 8, 2024

During my troubleshooting of #502 I noticed that the camera sends fragmented RTP packets, which are not handled correctly and trigger an exception.
I don't know if this has only been happening since Axis OS 11.11 or if it has been happening for a while.

wireshark excerpt:

no.	time		proto	size	info
388	14.018802	RTP	228	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3799, Time=2365376825, Mark
389	14.057391	RTP	992	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3800, Time=2365380299, Mark
390	14.107531	RTP	930	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3801, Time=2365384762, Mark
391	14.185768	RTP	1442	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3802, Time=2365391782
392	14.186232	RTP	228	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3803, Time=2365391782, Mark
393	14.323092	RTP	1442	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3804, Time=2365404094
394	14.323172	RTP	228	PT=DynamicRTP-Type-98, SSRC=0x1F93C2BA, Seq=3805, Time=2365404094, Mark

As one can see the packets with size 1442 have no marker bit set because they were fragmented, the remaining content is received immediately afterwards (see timestamp).

payload of packet no. 391:

<?xml version="1.0" encoding="UTF-8"?>
<tt:MetadataStream xmlns:tt="http://www.onvif.org/ver10/schema">
<tt:Event><wsnt:NotificationMessage xmlns:tns1="http://www.onvif.org/ver10/topics" mlns:tnsaxis="http://www.axis.com/2009/event/topics" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa5="http://www.w3.org/2005/08/addressing"><wsnt:Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple">tnsaxis:CameraApplicationPlatform/ObjectAnalytics/xinternal_data</wsnt:Topic><wsnt:ProducerReference><wsa5:Address>uri://cfbf96f2-9dc7-437f-aa12-155aacbb0b8f/ProducerReference</wsa5:Address></wsnt:ProducerReference><wsnt:Message><tt:Message UtcTime="2024-10-07T19:52:09.903990Z"><tt:Source></tt:Source><tt:Data><tt:SimpleItem Name="svgframe" Value="&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; baseProfile=&quot;full&quot; 
xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; 
width=&quot;100%&quot; height=&quot;100%&quot; 
viewBox=&quot;-1 -1 2 2 &quot; 
preserveAspectRatio=&quot;none&quot; &gt;
&lt;g transform=&quot;matrix(1 0 0 -1 0 0) matrix(1.0000 0.0000 0.0000 1.0000 0.0000 0.0000 )&quot; &gt;&lt;polygon class=&quot;&quot; points=&quot;0.970,-0.970 -0.480,-0.967 -0.949,-0.678 -0.976,-0.199 -0.866,-0.376 -0.752,-0.356 -0.970,0.970 &quot; style=&quot;fill:#FF0000;fill-opacity:0.2;stroke-opacity:1;stroke:#FF0000;stroke-width

payload of packet no. 392:

:2.5px;vector-effect:non-scaling-stroke&quot; /&gt;
&lt;/g&gt;&lt;/svg&gt;"/></tt:Data></tt:Message></wsnt:Message></wsnt:NotificationMessage></tt:Event></tt:MetadataStream>

@Kane610
Copy link
Owner

Kane610 commented Oct 10, 2024

Awesome! I'll get back to you during the weekend, you can start by adding a test that covers this situation

@swoga swoga force-pushed the fix-reassemble-rtp-fragments branch from f33c6ae to c3165a5 Compare October 10, 2024 20:20
@swoga
Copy link
Contributor Author

swoga commented Oct 10, 2024

added a test!

I had to adapt an existing test, because the dummy value 0123456789ABCDEF was used as data and therefore failed.
I replaced it with a "minimal RTP header" (zeros and only set the position of the RTP marker bit).

Copy link
Owner

@Kane610 Kane610 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@Kane610 Kane610 merged commit f34d13e into Kane610:master Oct 22, 2024
1 check passed
@Kane610
Copy link
Owner

Kane610 commented Oct 22, 2024

I will publish a release tonight

If you see more improvements don't hesitate to to contribute <3

@swoga swoga deleted the fix-reassemble-rtp-fragments branch October 22, 2024 18:35
@Kane610
Copy link
Owner

Kane610 commented Oct 22, 2024

Release is out, will you publish a PR for home assistant @swoga

@swoga
Copy link
Contributor Author

swoga commented Oct 22, 2024

Yes, I am happy to do it!

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