mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复webrtc开启simulcast推流时,统计观看人数线程安全相关bug (#2640)
This commit is contained in:
parent
077566d1e1
commit
fad8dd74e7
@ -59,11 +59,14 @@ bool WebRtcPusher::close(MediaSource &sender) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int WebRtcPusher::totalReaderCount(MediaSource &sender) {
|
int WebRtcPusher::totalReaderCount(MediaSource &sender) {
|
||||||
auto total_count = 0;
|
auto total_count = _push_src ? _push_src->totalReaderCount() : 0;
|
||||||
for (auto &src : _push_src_sim) {
|
if (_simulcast) {
|
||||||
total_count += src.second->totalReaderCount();
|
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 {
|
MediaOriginType WebRtcPusher::getOriginType(MediaSource &sender) const {
|
||||||
@ -96,6 +99,7 @@ void WebRtcPusher::onRecvRtp(MediaTrack &track, const string &rid, RtpPacket::Pt
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//视频
|
//视频
|
||||||
|
std::lock_guard<std::mutex> lock(_mtx);
|
||||||
auto &src = _push_src_sim[rid];
|
auto &src = _push_src_sim[rid];
|
||||||
if (!src) {
|
if (!src) {
|
||||||
const auto& stream = _push_src->getMediaTuple().stream;
|
const auto& stream = _push_src->getMediaTuple().stream;
|
||||||
|
@ -65,6 +65,7 @@ private:
|
|||||||
//推流所有权
|
//推流所有权
|
||||||
std::shared_ptr<void> _push_src_ownership;
|
std::shared_ptr<void> _push_src_ownership;
|
||||||
//推流的rtsp源,支持simulcast
|
//推流的rtsp源,支持simulcast
|
||||||
|
std::mutex _mtx;
|
||||||
std::unordered_map<std::string/*rid*/, RtspMediaSource::Ptr> _push_src_sim;
|
std::unordered_map<std::string/*rid*/, RtspMediaSource::Ptr> _push_src_sim;
|
||||||
std::unordered_map<std::string/*rid*/, std::shared_ptr<void> > _push_src_sim_ownership;
|
std::unordered_map<std::string/*rid*/, std::shared_ptr<void> > _push_src_sim_ownership;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user