提交 882c21ee authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Change Logger.hpp and WIP RembClient

上级 18c32d29
...@@ -17,27 +17,27 @@ ...@@ -17,27 +17,27 @@
* MS_TRACE() * MS_TRACE()
* *
* Logs the current method/function if MS_LOG_TRACE macro is defined and the * Logs the current method/function if MS_LOG_TRACE macro is defined and the
* current debug level is "debug". * current log level is "debug".
* *
* MS_HAS_DEBUG_TAG(tag) * MS_HAS_DEBUG_TAG(tag)
* MS_HAS_WARN_TAG(tag) * MS_HAS_WARN_TAG(tag)
* *
* True if the current debug level is satisfied and the given tag is enabled * True if the current log level is satisfied and the given tag is enabled.
* (or if the current source file defines the MS_LOG_DEV macro).
* *
* MS_DEBUG_TAG(tag, ...) * MS_DEBUG_TAG(tag, ...)
* MS_WARN_TAG(tag, ...) * MS_WARN_TAG(tag, ...)
* *
* Logs if the current debug level is satisfied and the given tag is enabled * Logs if the current log level is satisfied and the given tag is enabled.
* (or if the current source file defines the MS_LOG_DEV macro). *
* Example: * Example:
* MS_WARN_TAG(ice, "ICE failed"); * MS_WARN_TAG(ice, "ICE failed");
* *
* MS_DEBUG_2TAGS(tag1, tag2, ...) * MS_DEBUG_2TAGS(tag1, tag2, ...)
* MS_WARN_2TAGS(tag1, tag2, ...) * MS_WARN_2TAGS(tag1, tag2, ...)
* *
* Logs if the current debug level is satisfied and any of the given two tags * Logs if the current log level is satisfied and any of the given two tags
* is enabled (or if the current source file defines the MS_LOG_DEV macro). * is enabled.
*
* Example: * Example:
* MS_DEBUG_2TAGS(ice, dtls, "media connection established"); * MS_DEBUG_2TAGS(ice, dtls, "media connection established");
* *
...@@ -45,13 +45,14 @@ ...@@ -45,13 +45,14 @@
* MS_WARN_DEV(...) * MS_WARN_DEV(...)
* *
* Logs if the current source file defines the MS_LOG_DEV macro and the current * Logs if the current source file defines the MS_LOG_DEV macro and the current
* debug level is satisfied. * log level is satisfied.
*
* Example: * Example:
* MS_DEBUG_DEV("Producer closed [producerId:%" PRIu32 "]", producerId); * MS_DEBUG_DEV("Producer closed [producerId:%" PRIu32 "]", producerId);
* *
* MS_ERROR(...) * MS_ERROR(...)
* *
* Logs an error if the current debug level is satisfied (or if the current * Logs an error if the current log level is satisfied (or if the current
* source file defines the MS_LOG_DEV macro). Must just be used for internal * source file defines the MS_LOG_DEV macro). Must just be used for internal
* errors that should not happen. * errors that should not happen.
* *
...@@ -161,15 +162,15 @@ public: ...@@ -161,15 +162,15 @@ public:
#endif #endif
#define MS_HAS_DEBUG_TAG(tag) \ #define MS_HAS_DEBUG_TAG(tag) \
(Settings::configuration.logLevel == LogLevel::LOG_DEBUG && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED(tag))
#define MS_HAS_WARN_TAG(tag) \ #define MS_HAS_WARN_TAG(tag) \
(Settings::configuration.logLevel >= LogLevel::LOG_WARN && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED(tag))
#define MS_DEBUG_TAG(tag, desc, ...) \ #define MS_DEBUG_TAG(tag, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED(tag)) \
{ \ { \
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \ int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, loggerWritten); \ Logger::channel->SendLog(Logger::buffer, loggerWritten); \
...@@ -180,7 +181,7 @@ public: ...@@ -180,7 +181,7 @@ public:
#define MS_DEBUG_TAG_STD(tag, desc, ...) \ #define MS_DEBUG_TAG_STD(tag, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED(tag)) \
{ \ { \
std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \ std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stdout); \ std::fflush(stdout); \
...@@ -191,7 +192,7 @@ public: ...@@ -191,7 +192,7 @@ public:
#define MS_WARN_TAG(tag, desc, ...) \ #define MS_WARN_TAG(tag, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED(tag)) \
{ \ { \
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \ int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, loggerWritten); \ Logger::channel->SendLog(Logger::buffer, loggerWritten); \
...@@ -202,7 +203,7 @@ public: ...@@ -202,7 +203,7 @@ public:
#define MS_WARN_TAG_STD(tag, desc, ...) \ #define MS_WARN_TAG_STD(tag, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && (_MS_TAG_ENABLED(tag) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED(tag)) \
{ \ { \
std::fprintf(stderr, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \ std::fprintf(stderr, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stderr); \ std::fflush(stderr); \
...@@ -213,7 +214,7 @@ public: ...@@ -213,7 +214,7 @@ public:
#define MS_DEBUG_2TAGS(tag1, tag2, desc, ...) \ #define MS_DEBUG_2TAGS(tag1, tag2, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && (_MS_TAG_ENABLED_2(tag1, tag2) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \ { \
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \ int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "D" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, loggerWritten); \ Logger::channel->SendLog(Logger::buffer, loggerWritten); \
...@@ -224,7 +225,7 @@ public: ...@@ -224,7 +225,7 @@ public:
#define MS_DEBUG_2TAGS_STD(tag1, tag2, desc, ...) \ #define MS_DEBUG_2TAGS_STD(tag1, tag2, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && (_MS_TAG_ENABLED_2(tag1, tag2) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel == LogLevel::LOG_DEBUG && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \ { \
std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \ std::fprintf(stdout, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stdout); \ std::fflush(stdout); \
...@@ -235,7 +236,7 @@ public: ...@@ -235,7 +236,7 @@ public:
#define MS_WARN_2TAGS(tag1, tag2, desc, ...) \ #define MS_WARN_2TAGS(tag1, tag2, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && (_MS_TAG_ENABLED_2(tag1, tag2) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \ { \
int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \ int loggerWritten = std::snprintf(Logger::buffer, Logger::bufferSize, "W" _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__); \
Logger::channel->SendLog(Logger::buffer, loggerWritten); \ Logger::channel->SendLog(Logger::buffer, loggerWritten); \
...@@ -246,7 +247,7 @@ public: ...@@ -246,7 +247,7 @@ public:
#define MS_WARN_2TAGS_STD(tag1, tag2, desc, ...) \ #define MS_WARN_2TAGS_STD(tag1, tag2, desc, ...) \
do \ do \
{ \ { \
if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && (_MS_TAG_ENABLED_2(tag1, tag2) || _MS_LOG_DEV_ENABLED)) \ if (Settings::configuration.logLevel >= LogLevel::LOG_WARN && _MS_TAG_ENABLED_2(tag1, tag2)) \
{ \ { \
std::fprintf(stderr, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \ std::fprintf(stderr, _MS_LOG_STR_DESC desc _MS_LOG_SEPARATOR_CHAR_STD, _MS_LOG_ARG, ##__VA_ARGS__); \
std::fflush(stderr); \ std::fflush(stderr); \
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "RTC/RTCP/FeedbackPsRemb.hpp" #include "RTC/RTCP/FeedbackPsRemb.hpp"
#include "RTC/RtpDataCounter.hpp" #include "RTC/RtpDataCounter.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include <limits>
namespace RTC namespace RTC
{ {
...@@ -15,7 +16,9 @@ namespace RTC ...@@ -15,7 +16,9 @@ namespace RTC
{ {
public: public:
virtual void OnRembClientAvailableBitrate( virtual void OnRembClientAvailableBitrate(
RTC::RembClient* rembClient, int32_t availableBitrate) = 0; RTC::RembClient* rembClient, uint32_t availableBitrate) = 0;
virtual void OnRembClientExceedingBitrate(
RTC::RembClient* rembClient, uint32_t exceedingBitrate) = 0;
}; };
public: public:
...@@ -25,18 +28,19 @@ namespace RTC ...@@ -25,18 +28,19 @@ namespace RTC
public: public:
void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb); void ReceiveRembFeedback(RTC::RTCP::FeedbackPsRembPacket* remb);
uint32_t GetAvailableBitrate() const; uint32_t GetAvailableBitrate();
void AddExtraBitrate(uint32_t extraBitrate); void AddExtraBitrate(uint32_t extraBitrate);
void RemoveExtraBitrate(uint32_t extraBitrate); void RemoveExtraBitrate(uint32_t extraBitrate);
private:
bool HasRecentData() const;
private: private:
Listener* listener; Listener* listener;
RTC::RtpDataCounter transmissionCounter; RTC::RtpDataCounter transmissionCounter;
uint32_t bitrateInUse{ 0 };
uint32_t extraBitrateInUse{ 0 };
uint32_t rembBitrate{ 0 };
uint32_t availableBitrate{ 0 };
uint64_t lastEventAt{ 0 }; uint64_t lastEventAt{ 0 };
uint32_t rembBitrate{ 0 };
uint32_t availableBitrate{ std::numeric_limits<uint32_t>::max() };
}; };
} // namespace RTC } // namespace RTC
......
...@@ -107,7 +107,8 @@ namespace RTC ...@@ -107,7 +107,8 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RembClient::Listener. */ /* Pure virtual methods inherited from RTC::RembClient::Listener. */
public: public:
void OnRembClientAvailableBitrate(RTC::RembClient* rembClient, int32_t availableBitrate) override; void OnRembClientAvailableBitrate(RTC::RembClient* rembClient, uint32_t availableBitrate) override;
void OnRembClientExceedingBitrate(RTC::RembClient* rembClient, uint32_t exceedingBitrate) override;
/* Pure virtual methods inherited from RTC::RembServer::RemoteBitrateEstimator::Listener. */ /* Pure virtual methods inherited from RTC::RembServer::RemoteBitrateEstimator::Listener. */
public: public:
......
...@@ -241,6 +241,7 @@ namespace RTC ...@@ -241,6 +241,7 @@ namespace RTC
{ {
auto* consumer = kv.second; auto* consumer = kv.second;
if (consumer->IsActive())
consumer->UseBitrate(); consumer->UseBitrate();
} }
...@@ -418,9 +419,9 @@ namespace RTC ...@@ -418,9 +419,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
// If the Transport is already connected tell the new Consumer to use // If the Transport is already connected and the Consumer is active, tell the
// available bitrate. // new Consumer to use available bitrate.
if (IsConnected()) if (IsConnected() && consumer->IsActive())
consumer->UseBitrate(); consumer->UseBitrate();
} }
......
...@@ -418,6 +418,7 @@ namespace RTC ...@@ -418,6 +418,7 @@ namespace RTC
{ {
auto* consumer = kv.second; auto* consumer = kv.second;
if (consumer->IsActive())
consumer->UseBitrate(); consumer->UseBitrate();
} }
...@@ -690,9 +691,9 @@ namespace RTC ...@@ -690,9 +691,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
// If the Transport is already connected tell the new Consumer to use // If the Transport is already connected and the Consumer is active, tell the
// available bitrate. // new Consumer to use available bitrate.
if (IsConnected()) if (IsConnected() && consumer->IsActive())
consumer->UseBitrate(); consumer->UseBitrate();
} }
......
#define MS_CLASS "RTC::RembClient" #define MS_CLASS "RTC::RembClient"
#define MS_LOG_DEV // TODO // #define MS_LOG_DEV
#include "RTC/RembClient.hpp" #include "RTC/RembClient.hpp"
#include "DepLibUV.hpp" #include "DepLibUV.hpp"
#include "Logger.hpp" #include "Logger.hpp"
#include <limits>
namespace RTC namespace RTC
{ {
...@@ -40,13 +39,19 @@ namespace RTC ...@@ -40,13 +39,19 @@ namespace RTC
// Check if we should fire the event. // Check if we should fire the event.
uint64_t now = DepLibUV::GetTime(); uint64_t now = DepLibUV::GetTime();
if (now - this->lastEventAt >= MaxEventInterval) if (!HasRecentData())
{ {
MS_DEBUG_TAG(bwe, "ignoring first REMB after inactivity"); MS_DEBUG_DEV(bwe, "ignoring first REMB after inactivity");
// Update last event time. // Update last event time.
this->lastEventAt = now; this->lastEventAt = now;
// Set available bitrate to the maximum value.
this->availableBitrate = std::numeric_limits<uint32_t>::max();
// Update REMB bitrate.
this->rembBitrate = static_cast<uint32_t>(remb->GetBitrate());
return; return;
} }
else if (now - this->lastEventAt < EventInterval) else if (now - this->lastEventAt < EventInterval)
...@@ -54,65 +59,73 @@ namespace RTC ...@@ -54,65 +59,73 @@ namespace RTC
return; return;
} }
// Update last event time.
this->lastEventAt = now;
uint32_t newRembBitrate = static_cast<uint32_t>(remb->GetBitrate()); uint32_t newRembBitrate = static_cast<uint32_t>(remb->GetBitrate());
auto rembTrend = static_cast<int64_t>(newRembBitrate) - static_cast<int64_t>(this->rembBitrate); int64_t rembTrend =
static_cast<int64_t>(newRembBitrate) - static_cast<int64_t>(this->rembBitrate);
uint32_t bitrateInUse = this->transmissionCounter.GetRate(now);
// Update REMB bitrate. // Update REMB bitrate.
this->rembBitrate = newRembBitrate; this->rembBitrate = newRembBitrate;
// Update bitrate in use. if (this->rembBitrate >= bitrateInUse)
this->bitrateInUse = this->transmissionCounter.GetRate(now);
// Update last event time.
this->lastEventAt = now;
if (this->rembBitrate >= this->bitrateInUse)
{ {
uint32_t availableBitrate = this->rembBitrate - this->bitrateInUse; uint32_t availableBitrate = this->rembBitrate - bitrateInUse;
MS_DEBUG_TAG( MS_DEBUG_TAG(
bwe, bwe,
"available bitrate [REMB:%" PRIu32 " >= bitrateInUse:%" PRIu32 ", availableBitrate:%" PRIu32 "available bitrate [REMB:%" PRIu32 " >= bitrateInUse:%" PRIu32 ", availableBitrate:%" PRIu32
"]", "]",
this->rembBitrate, this->rembBitrate,
this->bitrateInUse, bitrateInUse,
availableBitrate); availableBitrate);
this->availableBitrate = availableBitrate;
this->listener->OnRembClientAvailableBitrate(this, availableBitrate);
} }
else if (rembTrend > 0) else if (rembTrend > 0)
{ {
MS_DEBUG_TAG( MS_DEBUG_TAG(
bwe, bwe,
"positive REMT trend [REMB:%" PRIu32 " < bitrateInUse:%" PRIu32 ", trend:%" PRIi64 "]", "positive REMB trend [REMB:%" PRIu32 " < bitrateInUse:%" PRIu32 ", trend:%" PRIi64 "]",
this->rembBitrate, this->rembBitrate,
this->bitrateInUse, bitrateInUse,
rembTrend); rembTrend);
this->availableBitrate = 0;
} }
else else
{ {
uint32_t exceedingBitrate = this->bitrateInUse - this->rembBitrate; uint32_t exceedingBitrate = bitrateInUse - this->rembBitrate;
MS_WARN_TAG( MS_WARN_TAG(
bwe, bwe,
"exceeding bitrate [REMB:%" PRIu32 " < bitrateInUse:%" PRIu32 ", exceedingBitrate:%" PRIu32 "exceeding bitrate [REMB:%" PRIu32 " < bitrateInUse:%" PRIu32 ", exceedingBitrate:%" PRIu32
"]", "]",
this->rembBitrate, this->rembBitrate,
this->bitrateInUse, bitrateInUse,
exceedingBitrate); exceedingBitrate);
this->availableBitrate = 0;
this->listener->OnRembClientExceedingBitrate(this, exceedingBitrate);
} }
} }
uint32_t RembClient::GetAvailableBitrate() const uint32_t RembClient::GetAvailableBitrate()
{ {
MS_TRACE(); MS_TRACE();
// if (this->bitrateInUse == 0) if (!HasRecentData())
// return std::numeric_limits<uint32_t>::max(); this->availableBitrate = std::numeric_limits<uint32_t>::max();
// else if (this->availableBitrate >= this->extraBitrateInUse)
// return this->availableBitrate - this->extraBitrateInUse; // TODO
// else MS_ERROR("--- availableBitrate:%" PRIu32, this->availableBitrate);
// return 0;
return 1234; return this->availableBitrate;
} }
void RembClient::AddExtraBitrate(uint32_t extraBitrate) void RembClient::AddExtraBitrate(uint32_t extraBitrate)
...@@ -122,8 +135,12 @@ namespace RTC ...@@ -122,8 +135,12 @@ namespace RTC
// Update last event time. // Update last event time.
this->lastEventAt = DepLibUV::GetTime(); this->lastEventAt = DepLibUV::GetTime();
// Increase extra bitrate in use. if (!HasRecentData())
this->extraBitrateInUse += extraBitrate; this->availableBitrate = std::numeric_limits<uint32_t>::max();
else if (this->availableBitrate > extraBitrate)
this->availableBitrate -= extraBitrate;
else
this->availableBitrate = 0;
} }
void RembClient::RemoveExtraBitrate(uint32_t extraBitrate) void RembClient::RemoveExtraBitrate(uint32_t extraBitrate)
...@@ -133,10 +150,18 @@ namespace RTC ...@@ -133,10 +150,18 @@ namespace RTC
// Update last event time. // Update last event time.
this->lastEventAt = DepLibUV::GetTime(); this->lastEventAt = DepLibUV::GetTime();
// Decrease extra bitrate in use. if (!HasRecentData())
if (this->extraBitrateInUse >= extraBitrate) this->availableBitrate = std::numeric_limits<uint32_t>::max();
this->extraBitrateInUse -= extraBitrate; else if (std::numeric_limits<uint32_t>::max() - this->availableBitrate > extraBitrate)
this->availableBitrate += extraBitrate;
else else
this->extraBitrateInUse = 0; this->availableBitrate = std::numeric_limits<uint32_t>::max();
}
inline bool RembClient::HasRecentData() const
{
MS_TRACE();
return (DepLibUV::GetTime() - this->lastEventAt < MaxEventInterval);
} }
} // namespace RTC } // namespace RTC
...@@ -142,11 +142,11 @@ namespace RTC ...@@ -142,11 +142,11 @@ namespace RTC
} }
else else
{ {
#ifdef MS_LOG_DEV
int sendBitrateBps = it->meanSize * 8 * 1000 / it->sendMeanMs; int sendBitrateBps = it->meanSize * 8 * 1000 / it->sendMeanMs;
int recvBitrateBps = it->meanSize * 8 * 1000 / it->recvMeanMs; int recvBitrateBps = it->meanSize * 8 * 1000 / it->recvMeanMs;
MS_DEBUG_TAG( MS_WARN_DEV(
bwe,
"probe failed, sent at %d bps, received at %d bps [mean " "probe failed, sent at %d bps, received at %d bps [mean "
"send delta:%fms, mean recv delta:%fms, num probes:%d]", "send delta:%fms, mean recv delta:%fms, num probes:%d]",
sendBitrateBps, sendBitrateBps,
...@@ -154,6 +154,7 @@ namespace RTC ...@@ -154,6 +154,7 @@ namespace RTC
it->sendMeanMs, it->sendMeanMs,
it->recvMeanMs, it->recvMeanMs,
it->count); it->count);
#endif
break; break;
} }
...@@ -189,8 +190,7 @@ namespace RTC ...@@ -189,8 +190,7 @@ namespace RTC
// reduce the estimate. // reduce the estimate.
if (IsBitrateImproving(probeBitrateBps)) if (IsBitrateImproving(probeBitrateBps))
{ {
MS_DEBUG_TAG( MS_DEBUG_DEV(
bwe,
"probe successful, sent at %d bps, received at %d bps " "probe successful, sent at %d bps, received at %d bps "
"[mean send delta:%fms, mean recv delta:%f ms, " "[mean send delta:%fms, mean recv delta:%f ms, "
"num probes:%d", "num probes:%d",
...@@ -308,8 +308,7 @@ namespace RTC ...@@ -308,8 +308,7 @@ namespace RTC
recvDeltaMs = arrivalTimeMs - this->probes.back().recvTimeMs; recvDeltaMs = arrivalTimeMs - this->probes.back().recvTimeMs;
} }
MS_DEBUG_TAG( MS_DEBUG_DEV(
bwe,
"probe packet received [send time:%" PRId64 "probe packet received [send time:%" PRId64
"ms, recv " "ms, recv "
"time:%" PRId64 "ms, send delta:%dms, recv delta:%d ms]", "time:%" PRId64 "ms, send delta:%dms, recv delta:%d ms]",
......
...@@ -1140,10 +1140,14 @@ namespace RTC ...@@ -1140,10 +1140,14 @@ namespace RTC
this->rembClient = new RTC::RembClient(this); this->rembClient = new RTC::RembClient(this);
} }
// If the Transport is already connected tell the new Consumer to use // If the Transport is already connected and the Consumer is active, tell the
// available bitrate. // new Consumer to use available bitrate.
if (IsConnected()) if (IsConnected() && consumer->IsActive())
{ {
// TODO
if (this->rembClient)
this->rembClient->GetAvailableBitrate();
// TODO // TODO
consumer->UseBitrate(); consumer->UseBitrate();
} }
...@@ -1167,6 +1171,10 @@ namespace RTC ...@@ -1167,6 +1171,10 @@ namespace RTC
if (!IsConnected()) if (!IsConnected())
return; return;
// TODO
if (this->rembClient)
this->rembClient->GetAvailableBitrate();
// TODO // TODO
consumer->UseBitrate(); consumer->UseBitrate();
} }
...@@ -1369,6 +1377,7 @@ namespace RTC ...@@ -1369,6 +1377,7 @@ namespace RTC
auto* consumer = kv.second; auto* consumer = kv.second;
// TODO // TODO
if (consumer->IsActive())
consumer->UseBitrate(); consumer->UseBitrate();
} }
} }
...@@ -1430,7 +1439,15 @@ namespace RTC ...@@ -1430,7 +1439,15 @@ namespace RTC
} }
inline void WebRtcTransport::OnRembClientAvailableBitrate( inline void WebRtcTransport::OnRembClientAvailableBitrate(
RTC::RembClient* rembClient, int32_t availableBitrate) RTC::RembClient* /*rembClient*/, uint32_t availableBitrate)
{
MS_TRACE();
// TODO
}
inline void WebRtcTransport::OnRembClientExceedingBitrate(
RTC::RembClient* /*rembClient*/, uint32_t exceedingBitrate)
{ {
MS_TRACE(); MS_TRACE();
...@@ -1458,11 +1475,13 @@ namespace RTC ...@@ -1458,11 +1475,13 @@ namespace RTC
ssrcsStream << ssrcs.back(); ssrcsStream << ssrcs.back();
} }
#ifdef MS_LOG_DEV
MS_DEBUG_TAG( MS_DEBUG_TAG(
bwe, bwe,
"sending RTCP REMB packet [bitrate:%" PRIu32 "bps, ssrcs:%s]", "sending RTCP REMB packet [bitrate:%" PRIu32 "bps, ssrcs:%s]",
availableBitrate, availableBitrate,
ssrcsStream.str().c_str()); ssrcsStream.str().c_str());
#endif
} }
RTC::RTCP::FeedbackPsRembPacket packet(0, 0); RTC::RTCP::FeedbackPsRembPacket packet(0, 0);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论