-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
referenceTime calculation error in FeedbackRtpTransport.cpp #874
Comments
CC @jmillan |
It's definitely odd. I wonder why we set that mask. Being a 3 byte field it should be What's the reason behind |
Indeed we need it to be a 23bit field, so the mask should be: |
There is indeed discussion/explanation about this here meetecho/janus-gateway#1733 (comment) @ibc , but I don't see why we set that mask. |
I'm checking it. |
Honestly I don't think I can give better rationale than the one given in that comment when it was fresh in my mind, but AFAIS I provide there even with code to demonstrate things. |
Got it: 0x1FFFFFC0 => 536870848 => 11111111111111111111111000000 Dividing such value by 64: 0x7FFFFF => 8388607 => 00000000011111111111111111111111 So by adding |
Where do you then see the problem @bianxg ? |
from webrtc source code, referenceTime is calculated as below: which is equals to |
I wrote one test:
I found definitely |
The difference is that mediasoup does NOT generate negative timestamp values. That's why we use 23 bits to represent it, so the most significant bit (sign) is always 0 and thus represent a positive number. |
Anyway, have you seen this is an issue for libwebrtc processing this RTCP packets? |
@jmillan There are int, int16_t, int32_t, int64_t etc types in C/C++, however, there is no 24-bit signed integer. And using the lowest 24 bits of a uint32_t type to assign and store can ensure reference_time is not negative. |
This was handled here #899 |
this->referenceTime = static_cast<int32_t>((timestamp & 0x1FFFFFC0) / 64);
should be (referenceTime is 3 byte long)
this->referenceTime = static_cast<int32_t>((timestamp & 0x3FFFFFC0) / 64);
for example
timestamp = 763974970
BIN 00101101100010010101010100111010
0x1FFFFFC0 is 00011111111111111111111111000000
from webrtc source
constexpr int kBaseScaleFactor = 64;
constexpr int64_t kTimeWrapPeriod = (1ll << 24) * kBaseScaleFactor;
this->referenceTime = static_cast<int32_t>((timestamp % kTimeWrapPeriod)/64);
The text was updated successfully, but these errors were encountered: