mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
修复断连续推情况下线程迁移导致崩溃的bug:#2283
如果一个MultiMediaSourceMuxer对象上挂载了很多个RtpSender对象, 这些对象会绑定MultiMediaSourceMuxer的OwnerPoller(归属线程), 在断连续推发生时,对应的MultiMediaSourceMuxer对象OwnerPoller线程 将发生变更,导致与RtpSender对象的线程不一致。
This commit is contained in:
parent
9188ed1613
commit
ba4296e180
@ -153,6 +153,8 @@ std::shared_ptr<void> MediaSource::getOwnership() {
|
||||
//已经被所有
|
||||
return nullptr;
|
||||
}
|
||||
// 关闭所有rtp推流,确保线程安全
|
||||
stopSendRtp("");
|
||||
weak_ptr<MediaSource> weak_self = shared_from_this();
|
||||
//确保返回的Ownership智能指针不为空,0x01无实际意义
|
||||
return std::shared_ptr<void>((void *) 0x01, [weak_self](void *ptr) {
|
||||
|
@ -246,6 +246,10 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
|
||||
if (!strong_self || ex) {
|
||||
return;
|
||||
}
|
||||
if (!strong_self->getOwnerPoller(MediaSource::NullMediaSource())->isCurrentThread()) {
|
||||
// poller线程发生变更了
|
||||
return;
|
||||
}
|
||||
for (auto &track : strong_self->getTracks(false)) {
|
||||
rtp_sender->addTrack(track);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user