mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-20 15:22:22 +08:00
修复webrtc开启simulcast推流时,统计观看人数线程安全相关bug (#2640)
This commit is contained in:
@@ -59,11 +59,14 @@ bool WebRtcPusher::close(MediaSource &sender) {
|
||||
}
|
||||
|
||||
int WebRtcPusher::totalReaderCount(MediaSource &sender) {
|
||||
auto total_count = 0;
|
||||
for (auto &src : _push_src_sim) {
|
||||
total_count += src.second->totalReaderCount();
|
||||
auto total_count = _push_src ? _push_src->totalReaderCount() : 0;
|
||||
if (_simulcast) {
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
for (auto &src : _push_src_sim) {
|
||||
total_count += src.second->totalReaderCount();
|
||||
}
|
||||
}
|
||||
return total_count + _push_src->totalReaderCount();
|
||||
return total_count;
|
||||
}
|
||||
|
||||
MediaOriginType WebRtcPusher::getOriginType(MediaSource &sender) const {
|
||||
@@ -96,6 +99,7 @@ void WebRtcPusher::onRecvRtp(MediaTrack &track, const string &rid, RtpPacket::Pt
|
||||
}
|
||||
} else {
|
||||
//视频
|
||||
std::lock_guard<std::mutex> lock(_mtx);
|
||||
auto &src = _push_src_sim[rid];
|
||||
if (!src) {
|
||||
const auto& stream = _push_src->getMediaTuple().stream;
|
||||
|
||||
Reference in New Issue
Block a user