-
-
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
libwebrtc: replace MS_ASSERT with MS_ERROR #988
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
#include <absl/memory/memory.h> | ||
#include <algorithm> | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
#define TODO_PRINT_PROBING_STATE() \ | ||
switch (probing_state_) \ | ||
{ \ | ||
|
@@ -80,7 +80,7 @@ BitrateProber::BitrateProber(const WebRtcKeyValueConfig& field_trials) | |
config_(&field_trials) { | ||
SetEnabled(true); | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
} | ||
|
||
|
@@ -95,7 +95,7 @@ void BitrateProber::SetEnabled(bool enable) { | |
MS_DEBUG_TAG(bwe, "Bandwidth probing disabled"); | ||
} | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
} | ||
|
||
|
@@ -114,7 +114,7 @@ void BitrateProber::OnIncomingPacket(size_t packet_size) { | |
probing_state_ = ProbingState::kActive; | ||
} | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
} | ||
|
||
|
@@ -123,8 +123,14 @@ void BitrateProber::CreateProbeCluster(int bitrate_bps, | |
int cluster_id) { | ||
// RTC_DCHECK(probing_state_ != ProbingState::kDisabled); | ||
// RTC_DCHECK_GT(bitrate_bps, 0); | ||
MS_ASSERT(probing_state_ != ProbingState::kDisabled, "probing disabled"); | ||
MS_ASSERT(bitrate_bps > 0, "bitrate must be > 0"); | ||
if (probing_state_ == ProbingState::kDisabled) { | ||
MS_ERROR("probing disabled"); | ||
return; | ||
} | ||
if (bitrate_bps <= 0) { | ||
MS_ERROR("bitrate must be > 0"); | ||
return; | ||
} | ||
|
||
total_probe_count_++; | ||
while (!clusters_.empty() && | ||
|
@@ -141,7 +147,10 @@ void BitrateProber::CreateProbeCluster(int bitrate_bps, | |
config_.min_probe_duration->ms() / 8000); | ||
|
||
// RTC_DCHECK_GE(cluster.pace_info.probe_cluster_min_bytes, 0); | ||
MS_ASSERT(cluster.pace_info.probe_cluster_min_bytes >= 0, "cluster min bytes must be >= 0"); | ||
if (cluster.pace_info.probe_cluster_min_bytes < 0) { | ||
MS_ERROR("cluster min bytes must be >= 0"); | ||
return; | ||
} | ||
|
||
cluster.pace_info.send_bitrate_bps = bitrate_bps; | ||
cluster.pace_info.probe_cluster_id = cluster_id; | ||
|
@@ -165,12 +174,12 @@ void BitrateProber::CreateProbeCluster(int bitrate_bps, | |
probing_state_ = ProbingState::kActive; | ||
} | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
} | ||
|
||
int BitrateProber::TimeUntilNextProbe(int64_t now_ms) { | ||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
|
||
// Probing is not active or probing is already complete. | ||
|
@@ -191,11 +200,12 @@ int BitrateProber::TimeUntilNextProbe(int64_t now_ms) { | |
return std::max(time_until_probe_ms, 0); | ||
} | ||
|
||
PacedPacketInfo BitrateProber::CurrentCluster() const { | ||
absl::optional<PacedPacketInfo> BitrateProber::CurrentCluster() const { | ||
// RTC_DCHECK(!clusters_.empty()); | ||
// RTC_DCHECK(probing_state_ == ProbingState::kActive); | ||
MS_ASSERT(!clusters_.empty(), "clusters is empty"); | ||
MS_ASSERT(probing_state_ == ProbingState::kActive, "probing not active"); | ||
if (clusters_.empty() || probing_state_ != ProbingState::kActive) { | ||
return absl::nullopt; | ||
} | ||
|
||
return clusters_.front().pace_info; | ||
} | ||
|
@@ -205,7 +215,9 @@ PacedPacketInfo BitrateProber::CurrentCluster() const { | |
// feasible. | ||
size_t BitrateProber::RecommendedMinProbeSize() const { | ||
// RTC_DCHECK(!clusters_.empty()); | ||
MS_ASSERT(!clusters_.empty(), "clusters is empty"); | ||
if (clusters_.empty()) { | ||
return 0; | ||
ibc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return clusters_.front().pace_info.send_bitrate_bps * 2 * | ||
config_.min_probe_delta->ms() / (8 * 1000); | ||
|
@@ -214,14 +226,23 @@ size_t BitrateProber::RecommendedMinProbeSize() const { | |
void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) { | ||
// RTC_DCHECK(probing_state_ == ProbingState::kActive); | ||
// RTC_DCHECK_GT(bytes, 0); | ||
MS_ASSERT(probing_state_ == ProbingState::kActive, "probing not active"); | ||
MS_ASSERT(bytes > 0, "bytes must be > 0"); | ||
if (probing_state_ != ProbingState::kActive) { | ||
MS_ERROR("probing not active"); | ||
return; | ||
} | ||
if (bytes <= 0) { | ||
MS_ERROR("bytes must be > 0"); | ||
return; | ||
} | ||
|
||
if (!clusters_.empty()) { | ||
ProbeCluster* cluster = &clusters_.front(); | ||
if (cluster->sent_probes == 0) { | ||
// RTC_DCHECK_EQ(cluster->time_started_ms, -1); | ||
MS_ASSERT(cluster->time_started_ms == -1, "cluster started time must not be -1"); | ||
if (cluster->time_started_ms != -1) { | ||
MS_ERROR("cluster started time must be -1"); | ||
return; | ||
} | ||
|
||
cluster->time_started_ms = now_ms; | ||
} | ||
|
@@ -242,16 +263,22 @@ void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) { | |
if (clusters_.empty()) | ||
probing_state_ = ProbingState::kSuspended; | ||
|
||
// TODO: jeje | ||
// TODO: Remove. | ||
TODO_PRINT_PROBING_STATE(); | ||
} | ||
} | ||
|
||
int64_t BitrateProber::GetNextProbeTime(const ProbeCluster& cluster) { | ||
// RTC_CHECK_GT(cluster.pace_info.send_bitrate_bps, 0); | ||
// RTC_CHECK_GE(cluster.time_started_ms, 0); | ||
MS_ASSERT(cluster.pace_info.send_bitrate_bps > 0, "cluster.pace_info.send_bitrate_bps must be > 0"); | ||
MS_ASSERT(cluster.time_started_ms > 0, "cluster.time_started_ms must be > 0"); | ||
if (cluster.pace_info.send_bitrate_bps <= 0) { | ||
MS_ERROR("cluster.pace_info.send_bitrate_bps must be > 0"); | ||
return 0; | ||
} | ||
if (cluster.time_started_ms <= 0) { | ||
MS_ERROR("cluster.time_started_ms must be > 0"); | ||
return 0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jmillan I'm gonna revert these changes because those were |
||
|
||
// Compute the time delta from the cluster start to ensure probe bitrate stays | ||
// close to the target bitrate. Result is in milliseconds. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ class BitrateProber { | |
int TimeUntilNextProbe(int64_t now_ms); | ||
|
||
// Information about the current probing cluster. | ||
PacedPacketInfo CurrentCluster() const; | ||
absl::optional<PacedPacketInfo> CurrentCluster() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from modern libwebrtc version. |
||
|
||
// Returns the minimum number of bytes that the prober recommends for | ||
// the next probe. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,15 +99,21 @@ bool PacedSender::Congested() const { | |
|
||
void PacedSender::SetProbingEnabled(bool enabled) { | ||
// RTC_CHECK_EQ(0, packet_counter_); | ||
MS_ASSERT(packet_counter_ == 0, "packet counter must be 0"); | ||
if (packet_counter_ != 0) { | ||
MS_ERROR("packet counter must be 0"); | ||
return; | ||
} | ||
|
||
prober_.SetEnabled(enabled); | ||
} | ||
|
||
void PacedSender::SetPacingRates(uint32_t pacing_rate_bps, | ||
uint32_t padding_rate_bps) { | ||
// RTC_DCHECK(pacing_rate_bps > 0); | ||
MS_ASSERT(pacing_rate_bps > 0, "pacing rate must be > 0"); | ||
if (pacing_rate_bps == 0) { | ||
MS_ERROR("pacing rate must be > 0"); | ||
return; | ||
} | ||
|
||
pacing_bitrate_kbps_ = pacing_rate_bps / 1000; | ||
padding_budget_.set_target_rate_kbps(padding_rate_bps / 1000); | ||
|
@@ -121,7 +127,10 @@ void PacedSender::SetPacingRates(uint32_t pacing_rate_bps, | |
void PacedSender::InsertPacket(size_t bytes) { | ||
// RTC_DCHECK(pacing_bitrate_kbps_ > 0) | ||
// << "SetPacingRate must be called before InsertPacket."; | ||
MS_ASSERT(pacing_bitrate_kbps_ > 0, "SetPacingRates() must be called before InsertPacket()"); | ||
if (pacing_bitrate_kbps_ <= 0) { | ||
MS_ERROR("SetPacingRates() must be called before InsertPacket()"); | ||
return; | ||
} | ||
|
||
prober_.OnIncomingPacket(bytes); | ||
|
||
|
@@ -185,7 +194,7 @@ void PacedSender::Process() { | |
PacedPacketInfo pacing_info; | ||
absl::optional<size_t> recommended_probe_size; | ||
|
||
pacing_info = prober_.CurrentCluster(); | ||
pacing_info = prober_.CurrentCluster().value_or(PacedPacketInfo()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hope this is ok. Used in libwebrtc modern version somewhere. |
||
recommended_probe_size = prober_.RecommendedMinProbeSize(); | ||
|
||
size_t bytes_sent = 0; | ||
|
@@ -266,7 +275,7 @@ PacedPacketInfo PacedSender::GetPacingInfo() { | |
PacedPacketInfo pacing_info; | ||
|
||
if (prober_.IsProbing()) { | ||
pacing_info = prober_.CurrentCluster(); | ||
pacing_info = prober_.CurrentCluster().value_or(PacedPacketInfo());; | ||
} | ||
|
||
return pacing_info; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,11 +108,8 @@ void OveruseEstimator::Update(int64_t t_delta, | |
E_[0][0] + E_[1][1] >= 0 && | ||
E_[0][0] * E_[1][1] - E_[0][1] * E_[1][0] >= 0 && E_[0][0] >= 0; | ||
|
||
MS_ASSERT(positive_semi_definite, "positive_semi_definite is not true"); | ||
|
||
if (!positive_semi_definite) { | ||
MS_ERROR("The over-use estimator's covariance matrix is no longer " | ||
"semi-definite."); | ||
MS_ERROR("the over-use estimator's covariance matrix is no longer semi-definite"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return missing here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no such a return in libwebrtc. |
||
} | ||
|
||
slope_ = slope_ + K[0] * residual; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how modern libwebrtc code looks.