Implementation for jitter

This commit is contained in:
dijunkun
2023-09-08 17:45:01 +08:00
parent dc11f50d82
commit 79c838629a
9 changed files with 177 additions and 34 deletions

View File

@@ -0,0 +1,38 @@
#include "rtp_video_sender.h"
#include <chrono>
RtpVideoSender::RtpVideoSender() {}
RtpVideoSender::~RtpVideoSender() {
if (send_thread_ && send_thread_->joinable()) {
send_thread_->join();
delete send_thread_;
send_thread_ = nullptr;
}
}
void RtpVideoSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
if (!send_thread_) {
send_thread_ = new std::thread(&RtpVideoSender::Process, this);
}
for (auto& rtp_packet : rtp_packets) {
start_ = true;
rtp_packe_queue_.push(rtp_packet);
}
}
void RtpVideoSender::Process() {
while (1) {
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);
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}