diff --git a/include/rtc/rembhandler.hpp b/include/rtc/rembhandler.hpp index cb9d4ccb5..6f98878a4 100644 --- a/include/rtc/rembhandler.hpp +++ b/include/rtc/rembhandler.hpp @@ -18,12 +18,12 @@ namespace rtc { /// Responds to REMB messages sent by the receiver. class RTC_CPP_EXPORT RembHandler final : public MediaHandler { - rtc::synchronized_callback mOnRemb; + rtc::synchronized_callback mOnRemb; public: /// Constructs the RembResponder object to notify whenever a bitrate /// @param onRemb The callback that gets called whenever a bitrate by the receiver - RembHandler(std::function onRemb); + RembHandler(std::function onRemb); void incoming(message_vector &messages, const message_callback &send) override; }; diff --git a/include/rtc/rtc.h b/include/rtc/rtc.h index 84b57f6cd..bc7aed65f 100644 --- a/include/rtc/rtc.h +++ b/include/rtc/rtc.h @@ -170,7 +170,7 @@ typedef void *(RTC_API *rtcInterceptorCallbackFunc)(int pc, const char *message, typedef void(RTC_API *rtcBufferedAmountLowCallbackFunc)(int id, void *ptr); typedef void(RTC_API *rtcAvailableCallbackFunc)(int id, void *ptr); typedef void(RTC_API *rtcPliHandlerCallbackFunc)(int tr, void *ptr); -typedef void(RTC_API *rtcRembHandlerCallbackFunc)(int tr, unsigned int numSSRC, unsigned int bitrate, void *ptr); +typedef void(RTC_API *rtcRembHandlerCallbackFunc)(int tr, unsigned int bitrate, void *ptr); // Log diff --git a/src/capi.cpp b/src/capi.cpp index 74128c0f0..4fa456392 100644 --- a/src/capi.cpp +++ b/src/capi.cpp @@ -1334,9 +1334,9 @@ int rtcChainPliHandler(int tr, rtcPliHandlerCallbackFunc cb) { int rtcChainRembHandler(int tr, rtcRembHandlerCallbackFunc cb) { return wrap([&] { auto track = getTrack(tr); - auto handler = std::make_shared([tr, cb](unsigned int numSSRC, unsigned int bitrate) { + auto handler = std::make_shared([tr, cb](unsigned int bitrate) { if (auto ptr = getUserPointer(tr)) - cb(tr, numSSRC, bitrate, *ptr); + cb(tr, bitrate, *ptr); }); track->chainMediaHandler(handler); return RTC_ERR_SUCCESS; diff --git a/src/rembhandler.cpp b/src/rembhandler.cpp index dcd03edd2..9eaad9f71 100644 --- a/src/rembhandler.cpp +++ b/src/rembhandler.cpp @@ -19,7 +19,7 @@ namespace rtc { -RembHandler::RembHandler(std::function onRemb) : mOnRemb(onRemb) {} +RembHandler::RembHandler(std::function onRemb) : mOnRemb(onRemb) {} void RembHandler::incoming(message_vector &messages, [[maybe_unused]] const message_callback &send) { for (const auto &message : messages) { @@ -28,10 +28,13 @@ void RembHandler::incoming(message_vector &messages, [[maybe_unused]] const mess auto header = reinterpret_cast(message->data() + offset); uint8_t payload_type = header->payloadType(); - if (payload_type == 206 && header->reportCount() == 15) { - auto remb = reinterpret_cast(message->data() + offset); - mOnRemb(remb->getNumSSRC(), remb->getBitrate()); - break; + 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') { + mOnRemb(remb->getBitrate()); + break; + } } offset += header->lengthInBytes();