Fix crash caused by multi threads during program termination

This commit is contained in:
dijunkun
2023-09-11 14:45:22 +08:00
parent 79c838629a
commit 0899fe2f1d
11 changed files with 199 additions and 122 deletions

View File

@@ -2,12 +2,14 @@
#define _RTP_VIDEO_SENDER_H_
#include <functional>
#include <mutex>
#include <thread>
#include "ringbuffer.h"
#include "rtp_packet.h"
#include "thread_base.h"
class RtpVideoSender {
class RtpVideoSender : public ThreadBase {
public:
RtpVideoSender();
~RtpVideoSender();
@@ -21,14 +23,18 @@ class RtpVideoSender {
rtp_packet_send_func_ = rtp_packet_send_func;
}
void Start();
void Stop();
private:
void Process();
bool Process() override;
private:
std::function<void(RtpPacket &)> rtp_packet_send_func_ = nullptr;
RingBuffer<RtpPacket> rtp_packe_queue_;
std::thread *send_thread_ = nullptr;
bool start_ = false;
bool stop_ = true;
std::mutex mutex_;
};
#endif