versatica / mediasoup

Cutting Edge WebRTC Video Conferencing
https://mediasoup.org
ISC License
6.18k stars 1.12k forks source link

Doubt with test #1315

Closed piranna closed 8 months ago

piranna commented 8 months ago

https://github.com/versatica/mediasoup/blame/e226f2f9dfcb3124d6a472b051353f75b3959290/node/src/test/test-DataConsumer.ts#L157-L167

Where does that 0 came from? I've reviewed the other tests and the source code and can't identify it... Does DataConsumers have a subchannel 0 by default? Or is it a bug, maybe from the filtering of 65536 subchannel?

ibc commented 8 months ago

65536 casted to unsigned 2^16 is 0.

No, we don't want to validate given numbers in TS later. User should be clever enough to know what uint16 means.

piranna commented 8 months ago

65536 casted to unsigned 2^16 is 0.

I suspected that was the culprit, thanks to confirm. Then based on the docs and the comment at https://github.com/versatica/mediasoup/blame/e226f2f9dfcb3124d6a472b051353f75b3959290/node/src/test/test-DataConsumer.ts#L114-L115, shouldn't it be ignored instead of casted / truncated / mod 2**16? Or that's what you mean by "No, we don't want to validate given numbers in TS later. User should be clever enough to know what uint16 means."?

ibc commented 8 months ago

It means that if user passes a wrong uint16 number it is internally truncated without checking it.

piranna commented 8 months ago

It means that if user passes a wrong uint16 number it is internally truncated without checking it.

So if it's bigger than 65535, it will be bounded to 65535, isn't it? Or will it be modulo 65536?

ibc commented 8 months ago

Modulo. 35536 becomes 0 as in the test.

piranna commented 8 months ago

Great, thanks to confirm :-)