mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 20:55:38 +08:00
Implementation for jitter
This commit is contained in:
38
src/rtp/rtp_video_sender.cpp
Normal file
38
src/rtp/rtp_video_sender.cpp
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user