Add rtp video statistics module

This commit is contained in:
dijunkun
2023-09-11 16:15:46 +08:00
parent a2d7bb7ff5
commit 3a291fe171
8 changed files with 120 additions and 9 deletions

View File

@@ -6,23 +6,36 @@
RtpVideoSender::RtpVideoSender() {}
RtpVideoSender::~RtpVideoSender() {}
RtpVideoSender::~RtpVideoSender() { rtp_video_send_statistics_->Stop(); }
void RtpVideoSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
if (!rtp_video_send_statistics_) {
rtp_video_send_statistics_ = std::make_unique<RtpVideoSendStatistics>();
rtp_video_send_statistics_->Start();
}
for (auto& rtp_packet : rtp_packets) {
rtp_packe_queue_.push(rtp_packet);
}
}
bool RtpVideoSender::Process() {
for (size_t i = 0; i < 50; i++)
last_send_bytes_ = 0;
for (size_t i = 0; i < 10; i++)
if (!rtp_packe_queue_.isEmpty()) {
RtpPacket rtp_packet;
rtp_packe_queue_.pop(rtp_packet);
if (rtp_packet_send_func_) {
rtp_packet_send_func_(rtp_packet);
last_send_bytes_ += rtp_packet.Size();
}
}
if (rtp_video_send_statistics_) {
rtp_video_send_statistics_->UpdateSentBytes(last_send_bytes_);
}
std::this_thread::sleep_for(std::chrono::milliseconds(5));
return true;
}