mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 19:51:49 +08:00
简化事件参数
This commit is contained in:
@@ -221,13 +221,13 @@ private:
|
||||
_notice_center = NoticeCenter::Instance().shared_from_this();
|
||||
_notice_center->addListener(this,Broadcast::kBroadcastMediaChanged,[this](BroadcastMediaChangedArgs){
|
||||
if(bRegist){
|
||||
onRegist(schema,vhost,app,stream,sender);
|
||||
onRegist(sender);
|
||||
}else{
|
||||
onUnRegist(schema,vhost,app,stream,sender);
|
||||
onUnRegist(sender);
|
||||
}
|
||||
});
|
||||
_notice_center->addListener(this,Broadcast::kBroadcastMediaResetTracks,[this](BroadcastMediaResetTracksArgs){
|
||||
onRegist(schema,vhost,app,stream,sender);
|
||||
onRegist(sender);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -236,8 +236,8 @@ private:
|
||||
_notice_center->delListener(this,Broadcast::kBroadcastMediaResetTracks);
|
||||
}
|
||||
|
||||
void onRegist(const string &schema,const string &vhost,const string &app,const string &stream,MediaSource &sender){
|
||||
auto key = getRecorderKey(vhost,app,stream);
|
||||
void onRegist(MediaSource &sender){
|
||||
auto key = getRecorderKey(sender.getVhost(),sender.getApp(),sender.getId());
|
||||
lock_guard<decltype(_recorder_mtx)> lck(_recorder_mtx);
|
||||
auto it = _recorder_map.find(key);
|
||||
if(it == _recorder_map.end()){
|
||||
@@ -245,20 +245,20 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
if(!it->second->isRecording() || it->second->getSchema() == schema){
|
||||
if(!it->second->isRecording() || it->second->getSchema() == sender.getSchema()){
|
||||
// 绑定的协议一致或者并未正在录制则替换tracks
|
||||
auto tracks = sender.getTracks(true);
|
||||
if (!tracks.empty()) {
|
||||
it->second->attachTracks(std::move(tracks),schema);
|
||||
it->second->attachTracks(std::move(tracks),sender.getSchema());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onUnRegist(const string &schema,const string &vhost,const string &app,const string &stream,MediaSource &sender){
|
||||
auto key = getRecorderKey(vhost,app,stream);
|
||||
void onUnRegist(MediaSource &sender){
|
||||
auto key = getRecorderKey(sender.getVhost(),sender.getApp(),sender.getId());
|
||||
lock_guard<decltype(_recorder_mtx)> lck(_recorder_mtx);
|
||||
auto it = _recorder_map.find(key);
|
||||
if(it == _recorder_map.end() || it->second->getSchema() != schema){
|
||||
if(it == _recorder_map.end() || it->second->getSchema() != sender.getSchema()){
|
||||
// 录像记录不存在或绑定的协议不一致
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user