mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
修复RtpProcess析构导致的线程问题
This commit is contained in:
parent
f5a032c9a0
commit
bfe118d94e
@ -49,10 +49,13 @@ RtpProcess::RtpProcess(const string &stream_id) {
|
||||
}
|
||||
}
|
||||
|
||||
RtpProcess::~RtpProcess() {
|
||||
void RtpProcess::flush() {
|
||||
if (_process) {
|
||||
_process->flush();
|
||||
}
|
||||
}
|
||||
|
||||
RtpProcess::~RtpProcess() {
|
||||
uint64_t duration = (_last_frame_time.createdTime() - _last_frame_time.elapsedTime()) / 1000;
|
||||
WarnP(this) << "RTP推流器("
|
||||
<< _media_info.shortUrl()
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
class RtpProcess : public RtcpContextForRecv, public toolkit::SockInfo, public MediaSinkInterface, public MediaSourceEventInterceptor, public std::enable_shared_from_this<RtpProcess>{
|
||||
class RtpProcess final : public RtcpContextForRecv, public toolkit::SockInfo, public MediaSinkInterface, public MediaSourceEventInterceptor, public std::enable_shared_from_this<RtpProcess>{
|
||||
public:
|
||||
typedef std::shared_ptr<RtpProcess> Ptr;
|
||||
friend class RtpProcessHelper;
|
||||
@ -57,6 +57,11 @@ public:
|
||||
*/
|
||||
void setStopCheckRtp(bool is_check=false);
|
||||
|
||||
/**
|
||||
* flush输出缓存
|
||||
*/
|
||||
void flush() override;
|
||||
|
||||
/// SockInfo override
|
||||
std::string get_local_ip() override;
|
||||
uint16_t get_local_port() override;
|
||||
|
@ -112,6 +112,13 @@ RtpProcessHelper::RtpProcessHelper(const string &stream_id, const weak_ptr<RtpSe
|
||||
}
|
||||
|
||||
RtpProcessHelper::~RtpProcessHelper() {
|
||||
auto process = std::move(_process);
|
||||
try {
|
||||
// flush时,确保线程安全
|
||||
process->getOwnerPoller(MediaSource::NullMediaSource())->async([process]() { process->flush(); });
|
||||
} catch (...) {
|
||||
// 忽略getOwnerPoller可能抛出的异常
|
||||
}
|
||||
}
|
||||
|
||||
void RtpProcessHelper::attachEvent() {
|
||||
|
Loading…
Reference in New Issue
Block a user