Unverified 提交 f383e28a authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

AudioLevelObserver: use multimap rather than map to avoid conflict (#1021)

上级 37d542f0
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
### Next ### Next
* `AudioLevelObserver`: Use multimap rather than map to avoid conflict if various Producers generate same audio level ([PR #1021](https://github.com/versatica/mediasoup/pull/1021), issue reported by @buptlsp).
* Update NPM deps. * Update NPM deps.
......
...@@ -156,7 +156,7 @@ namespace RTC ...@@ -156,7 +156,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
absl::btree_map<int8_t, RTC::Producer*> mapDBovsProducer; absl::btree_multimap<int8_t, RTC::Producer*> mapDBovsProducer;
for (auto& kv : this->mapProducerDBovs) for (auto& kv : this->mapProducerDBovs)
{ {
...@@ -164,12 +164,16 @@ namespace RTC ...@@ -164,12 +164,16 @@ namespace RTC
auto& dBovs = kv.second; auto& dBovs = kv.second;
if (dBovs.count < 10) if (dBovs.count < 10)
{
continue; continue;
}
auto avgDBov = -1 * static_cast<int8_t>(std::lround(dBovs.totalSum / dBovs.count)); auto avgDBov = -1 * static_cast<int8_t>(std::lround(dBovs.totalSum / dBovs.count));
if (avgDBov >= this->threshold) if (avgDBov >= this->threshold)
mapDBovsProducer[avgDBov] = producer; {
mapDBovsProducer.insert({ avgDBov, producer });
}
} }
// Clear the map. // Clear the map.
...@@ -198,7 +202,6 @@ namespace RTC ...@@ -198,7 +202,6 @@ namespace RTC
else if (!this->silence) else if (!this->silence)
{ {
this->silence = true; this->silence = true;
this->shared->channelNotifier->Emit(this->id, "silence"); this->shared->channelNotifier->Emit(this->id, "silence");
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论