提交 735bab66 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

- RtpStream: s/GetRate/GetBitrate/g

- RtpStreamRecv: fix GetLayerBitrate()
- RtpStreamRecv: add "bitrateByLayer" in stats
上级 b77c933f
......@@ -54,7 +54,7 @@ namespace RTC
public:
void Update(RTC::RtpPacket* packet);
uint32_t GetRate(uint64_t now);
uint32_t GetBitrate(uint64_t now);
size_t GetPacketCount() const;
size_t GetBytes() const;
......@@ -87,7 +87,7 @@ namespace RTC
this->oldestTime = now - this->windowSize;
}
inline uint32_t RtpDataCounter::GetRate(uint64_t now)
inline uint32_t RtpDataCounter::GetBitrate(uint64_t now)
{
return this->rate.GetRate(now);
}
......
......@@ -29,9 +29,9 @@ namespace RTC
public:
TransmissionCounter(uint8_t spatialLayers, uint8_t temporalLayers);
void Update(RTC::RtpPacket* packet);
uint32_t GetRate(uint64_t now);
uint32_t GetRate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer);
uint32_t GetLayerRate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer);
uint32_t GetBitrate(uint64_t now);
uint32_t GetBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer);
uint32_t GetLayerBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer);
size_t GetPacketCount() const;
size_t GetBytes() const;
......@@ -46,7 +46,6 @@ namespace RTC
void FillJsonStats(json& jsonObject) override;
bool ReceivePacket(RTC::RtpPacket* packet) override;
bool ReceiveRtxPacket(RTC::RtpPacket* packet);
uint32_t GetRate(uint64_t now);
RTC::RTCP::ReceiverReport* GetRtcpReceiverReport();
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
void RequestKeyFrame();
......@@ -90,17 +89,17 @@ namespace RTC
inline uint32_t RtpStreamRecv::GetBitrate(uint64_t now)
{
return this->transmissionCounter.GetRate(now);
return this->transmissionCounter.GetBitrate(now);
}
inline uint32_t RtpStreamRecv::GetBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer)
{
return this->transmissionCounter.GetRate(now, spatialLayer, temporalLayer);
return this->transmissionCounter.GetBitrate(now, spatialLayer, temporalLayer);
}
inline uint32_t RtpStreamRecv::GetLayerBitrate(uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer)
{
return this->transmissionCounter.GetRate(now, spatialLayer, temporalLayer);
return this->transmissionCounter.GetLayerBitrate(now, spatialLayer, temporalLayer);
}
} // namespace RTC
......
......@@ -82,7 +82,7 @@ namespace RTC
inline uint32_t RtpStreamSend::GetBitrate(uint64_t now)
{
return this->transmissionCounter.GetRate(now);
return this->transmissionCounter.GetBitrate(now);
}
} // namespace RTC
......
......@@ -63,7 +63,7 @@ namespace RTC
int64_t trend =
static_cast<int64_t>(this->availableBitrate) - static_cast<int64_t>(previousAvailableBitrate);
uint32_t usedBitrate = this->transmissionCounter.GetRate(now);
uint32_t usedBitrate = this->transmissionCounter.GetBitrate(now);
if (this->availableBitrate >= usedBitrate)
{
......
......@@ -44,7 +44,7 @@ namespace RTC
counter.Update(packet);
}
uint32_t RtpStreamRecv::TransmissionCounter::GetRate(uint64_t now)
uint32_t RtpStreamRecv::TransmissionCounter::GetBitrate(uint64_t now)
{
uint32_t rate{ 0u };
......@@ -52,14 +52,14 @@ namespace RTC
{
for (auto& temporalLayerCounter : spatialLayerCounter)
{
rate += temporalLayerCounter.GetRate(now);
rate += temporalLayerCounter.GetBitrate(now);
}
}
return rate;
}
uint32_t RtpStreamRecv::TransmissionCounter::GetRate(
uint32_t RtpStreamRecv::TransmissionCounter::GetBitrate(
uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer)
{
uint32_t rate{ 0u };
......@@ -70,7 +70,7 @@ namespace RTC
{
for (auto& temporalLayerCounter : spatialLayerCounter)
{
rate += temporalLayerCounter.GetRate(now);
rate += temporalLayerCounter.GetBitrate(now);
if (++temporalLayerIdx > temporalLayer)
break;
......@@ -113,7 +113,7 @@ namespace RTC
return bytes;
}
uint32_t RtpStreamRecv::TransmissionCounter::GetLayerRate(
uint32_t RtpStreamRecv::TransmissionCounter::GetLayerBitrate(
uint64_t now, uint8_t spatialLayer, uint8_t temporalLayer)
{
// Sanity check. Do not allow spatial layers higher than defined.
......@@ -126,7 +126,7 @@ namespace RTC
auto& counter = this->spatialLayerCounters.at(spatialLayer).at(temporalLayer);
return counter.GetRate(now);
return counter.GetBitrate(now);
}
/* Instance methods. */
......@@ -173,7 +173,22 @@ namespace RTC
jsonObject["jitter"] = this->jitter;
jsonObject["packetCount"] = this->transmissionCounter.GetPacketCount();
jsonObject["byteCount"] = this->transmissionCounter.GetBytes();
jsonObject["bitrate"] = this->transmissionCounter.GetRate(now);
jsonObject["bitrate"] = this->transmissionCounter.GetBitrate(now);
if (GetSpatialLayers() > 1 || GetTemporalLayers() > 1)
{
jsonObject["bitrateByLayer"] = json::object();
auto jsonLayerBitrateIt = jsonObject.find("bitrateByLayer");
for (uint8_t sIdx = 0; sIdx < GetSpatialLayers(); ++sIdx)
{
for (uint8_t tIdx = 0; tIdx < GetTemporalLayers(); ++tIdx)
{
(*jsonLayerBitrateIt)[std::to_string(sIdx) + "." + std::to_string(tIdx)] =
GetLayerBitrate(now, sIdx, tIdx);
}
}
}
}
bool RtpStreamRecv::ReceivePacket(RTC::RtpPacket* packet)
......@@ -612,7 +627,7 @@ namespace RTC
auto now = DepLibUV::GetTime();
// If no RTP is being received reset the score.
if (this->transmissionCounter.GetRate(now) == 0)
if (this->transmissionCounter.GetBitrate(now) == 0)
{
this->inactive = true;
this->inactivityCheckPeriodicTimer->Stop();
......
......@@ -48,7 +48,7 @@ namespace RTC
jsonObject["roundTripTime"] = this->rtt;
jsonObject["packetCount"] = this->transmissionCounter.GetPacketCount();
jsonObject["byteCount"] = this->transmissionCounter.GetBytes();
jsonObject["bitrate"] = this->transmissionCounter.GetRate(now);
jsonObject["bitrate"] = this->transmissionCounter.GetBitrate(now);
}
bool RtpStreamSend::ReceivePacket(RTC::RtpPacket* packet)
......
......@@ -101,6 +101,33 @@ namespace RTC
{
MS_TRACE();
auto now = DepLibUV::GetTime();
// TODO
for (auto* rtpStream : this->producerRtpStreams)
{
if (!rtpStream)
continue;
MS_ERROR("Producer RtpStream [total bitrate:%" PRIu32 "]", rtpStream->GetBitrate(now));
for (uint8_t sIdx = 0; sIdx < rtpStream->GetSpatialLayers(); ++sIdx)
{
for (uint8_t tIdx = 0; tIdx < rtpStream->GetTemporalLayers(); ++tIdx)
{
MS_ERROR(
"- [spatial:%" PRIu8 ", temporal:%" PRIu8 ", layer bitrate:%" PRIu32
", total bitrate:%" PRIu32 "]",
sIdx,
tIdx,
rtpStream->GetLayerBitrate(now, sIdx, tIdx),
rtpStream->GetBitrate(now, sIdx, tIdx));
}
}
return;
}
// Call the parent method.
RTC::Consumer::FillJson(jsonObject);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论