mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Start thread after created when use ThreadBase
This commit is contained in:
@@ -88,22 +88,7 @@ bool RtpVideoReceiver::CheckIsFrameCompleted(RtpPacket& rtp_packet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RtpVideoReceiver::Start() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
stop_ = false;
|
||||
}
|
||||
|
||||
void RtpVideoReceiver::Stop() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
stop_ = true;
|
||||
}
|
||||
|
||||
bool RtpVideoReceiver::Process() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
if (stop_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!compelete_video_frame_queue_.isEmpty()) {
|
||||
VideoFrame video_frame;
|
||||
compelete_video_frame_queue_.pop(video_frame);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "frame.h"
|
||||
@@ -24,9 +23,6 @@ class RtpVideoReceiver : public ThreadBase {
|
||||
on_receive_complete_frame_ = on_receive_complete_frame;
|
||||
}
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
bool CheckIsFrameCompleted(RtpPacket& rtp_packet);
|
||||
// void OnReceiveFrame(uint8_t* payload) {}
|
||||
@@ -41,9 +37,6 @@ class RtpVideoReceiver : public ThreadBase {
|
||||
uint32_t last_complete_frame_ts_ = 0;
|
||||
|
||||
RingBuffer<VideoFrame> compelete_video_frame_queue_;
|
||||
|
||||
bool stop_ = true;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,22 +14,7 @@ void RtpVideoSender::Enqueue(std::vector<RtpPacket>& rtp_packets) {
|
||||
}
|
||||
}
|
||||
|
||||
void RtpVideoSender::Start() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
stop_ = false;
|
||||
}
|
||||
|
||||
void RtpVideoSender::Stop() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
stop_ = true;
|
||||
}
|
||||
|
||||
bool RtpVideoSender::Process() {
|
||||
std::lock_guard<std::mutex> lock_guard(mutex_);
|
||||
if (stop_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 50; i++)
|
||||
if (!rtp_packe_queue_.isEmpty()) {
|
||||
RtpPacket rtp_packet;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#define _RTP_VIDEO_SENDER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "ringbuffer.h"
|
||||
#include "rtp_packet.h"
|
||||
@@ -23,18 +21,12 @@ class RtpVideoSender : public ThreadBase {
|
||||
rtp_packet_send_func_ = rtp_packet_send_func;
|
||||
}
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
bool Process() override;
|
||||
|
||||
private:
|
||||
std::function<void(RtpPacket &)> rtp_packet_send_func_ = nullptr;
|
||||
RingBuffer<RtpPacket> rtp_packe_queue_;
|
||||
|
||||
bool stop_ = true;
|
||||
std::mutex mutex_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user