MediaSource: 禁止重复推送一个已经注册的流

This commit is contained in:
ziyue 2021-11-19 15:33:16 +08:00
parent afdc5e4267
commit 0b79de9d13

View File

@ -418,7 +418,11 @@ void MediaSource::regist() {
{
//减小互斥锁临界区
lock_guard<recursive_mutex> lock(s_media_source_mtx);
s_media_source_map[_schema][_vhost][_app][_stream_id] = shared_from_this();
auto &ref = s_media_source_map[_schema][_vhost][_app][_stream_id];
if (ref.lock()) {
throw std::invalid_argument("media source already existed:" + _schema + "/" + _vhost + "/" + _app + "/" + _stream_id);
}
ref = shared_from_this();
}
emitEvent(true);
}