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

"invalid TMMB bitrate value" #89

Closed
ibc opened this issue Mar 31, 2017 · 8 comments
Closed

"invalid TMMB bitrate value" #89

ibc opened this issue Mar 31, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@ibc
Copy link
Member

ibc commented Mar 31, 2017

In master branch:

RTC::RTCP::FeedbackRtpTmmb::FeedbackRtpTmmbItem() | invalid TMMB bitrate value : 43461 *2^63
@ibc ibc added the bug label Mar 31, 2017
@ibc ibc added this to the 1.0.0 milestone Mar 31, 2017
@jmillan
Copy link
Member

jmillan commented Mar 31, 2017

The value may indeed be invalid :-). I'll check it.

@ibc
Copy link
Member Author

ibc commented Mar 31, 2017

NOTE: I also see this:

RTC::Peer::onTransportRtcpPacket() | ignoring unsupported Feedback packet 'TMMBN' [sender_ssrc:0, media_ssrc:0]

media_ssrc:0?

@jmillan
Copy link
Member

jmillan commented Mar 31, 2017

It's Okey, the useful info is in the packet items, which contains the SSRCs they refer to, each. This packet type to be properly handled (forwarded) as commented this morning.

@ibc
Copy link
Member Author

ibc commented Mar 31, 2017

opps, ok ok, sorry.

@ibc
Copy link
Member Author

ibc commented Apr 1, 2017

I don't think this is ok:

	template <typename T>
	FeedbackRtpTmmbItem<T>::FeedbackRtpTmmbItem(const uint8_t* data)
	{

		this->ssrc = Utils::Byte::Get4Bytes(data, 0);

		// Read the 4 bytes block.
		uint32_t compact = Utils::Byte::Get4Bytes(data, 4);

		// Read each component.
		uint8_t exponent = compact >> 26;              // 6 bits.
		uint64_t mantissa = (compact >> 9) & 0x1ffff;  // 17 bits.
		this-> overhead = compact & 0x1ff;             // 9 bits.

Here we are reading bytes from 5 to 8 as a uint32_t number, and then split it into components. Is that right?

@ibc
Copy link
Member Author

ibc commented Apr 3, 2017

What mostly worries me (but I'd may be 100% wrong) is this:

template <typename T>
FeedbackRtpTmmbItem<T>::FeedbackRtpTmmbItem(const uint8_t* data)
{
	this->ssrc = Utils::Byte::Get4Bytes(data, 0);

	// Read the 4 bytes block.
	uint32_t compact = Utils::Byte::Get4Bytes(data, 4);

	// Read each component.
	uint8_t exponent = compact >> 26;              // 6 bits.
	uint64_t mantissa = (compact >> 9) & 0x1ffff;  // 17 bits.
	this-> overhead = compact & 0x1ff;             // 9 bits.

	// Get the bitrate out of exponent and mantissa.
	this->bitrate = (mantissa << exponent);

	if ((this->bitrate >> exponent) != mantissa)
	{
		MS_WARN_TAG(rtcp, "invalid TMMB bitrate value : %" PRIu64" *2^%" PRIu8, mantissa, exponent);

		this->isCorrect = false;
	}
}

I mean: that seems to be a pure mathematical assertion, how can it be wrong?

@jmillan
Copy link
Member

jmillan commented Apr 3, 2017

That check it to prevent shift overflows. Ie:

RTC::RTCP::FeedbackRtpTmmb::FeedbackRtpTmmbItem() | invalid TMMB bitrate value : 43461 *2^63

mantissa = 43461
exponent = 63

bitrate = mantissa << exponent = 9223372036854775807 (in a uint64_t)
bitrate >> exponent != bitrate

@ibc
Copy link
Member Author

ibc commented Apr 6, 2017

Closing due to same reasons as those in #93

@ibc ibc closed this as completed Apr 6, 2017
@ibc ibc modified the milestones: 1.0.0, v1 Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants