diff --git a/src/rembhandler.cpp b/src/rembhandler.cpp index 9eaad9f71..17738194d 100644 --- a/src/rembhandler.cpp +++ b/src/rembhandler.cpp @@ -17,11 +17,18 @@ #if RTC_ENABLE_MEDIA +static inline uint32_t makeEndianAgnosticValue(uint32_t value) { + return ((uint8_t *)&value)[0] | (((uint8_t *)&value)[1] << 8) | (((uint8_t *)&value)[2] << 16) | + (((uint8_t *)&value)[3] << 24); +} + namespace rtc { RembHandler::RembHandler(std::function onRemb) : mOnRemb(onRemb) {} void RembHandler::incoming(message_vector &messages, [[maybe_unused]] const message_callback &send) { + static uint32_t rembValue = makeEndianAgnosticValue('BMER'); + for (const auto &message : messages) { size_t offset = 0; while ((sizeof(RtcpHeader) + offset) <= message->size()) { @@ -31,7 +38,7 @@ void RembHandler::incoming(message_vector &messages, [[maybe_unused]] const mess if (payload_type == 206 && header->reportCount() == 15 && header->lengthInBytes() == sizeof(RtcpRemb)) { auto remb = reinterpret_cast(message->data() + offset); - if (remb->_id[0] == 'R' && remb->_id[1] == 'E' && remb->_id[2] == 'M' && remb->_id[3] == 'B') { + if (*(reinterpret_cast(&remb->_id)) == rembValue) { mOnRemb(remb->getBitrate()); break; }