1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

When for traverses the device list, send invite and sleep to other threads to update the list, and the conflicting program exits

This commit is contained in:
xialixin@kanzhun.com 2020-08-29 10:41:12 +08:00 committed by winlin
parent d02b560217
commit 82f1569f2a

View file

@ -163,7 +163,8 @@ srs_error_t SrsGb28181SipSession::do_cycle()
if (_register_status == SrsGb28181SipSessionRegisterOk && if (_register_status == SrsGb28181SipSessionRegisterOk &&
_alive_status == SrsGb28181SipSessionAliveOk) _alive_status == SrsGb28181SipSessionAliveOk)
{ {
std::list<std::string> auto_play_list;
std::map<std::string, SrsGb28181Device*>::iterator it; std::map<std::string, SrsGb28181Device*>::iterator it;
for (it = _device_list.begin(); it != _device_list.end(); it++) { for (it = _device_list.begin(); it != _device_list.end(); it++) {
SrsGb28181Device *device = it->second; SrsGb28181Device *device = it->second;
@ -191,8 +192,15 @@ srs_error_t SrsGb28181SipSession::do_cycle()
//offline or already invite device does not need to send invite //offline or already invite device does not need to send invite
if (device->device_status != "ON" || if (device->device_status != "ON" ||
device->invite_status != SrsGb28181SipSessionUnkonw) continue; device->invite_status != SrsGb28181SipSessionUnkonw) continue;
auto_play_list.push_back(chid);
}//end for (it)
//auto send sip invite and create stream chennal
while(auto_play_list.size() > 0){
std::string chid = auto_play_list.front();
auto_play_list.pop_front();
SrsGb28181StreamChannel ch; SrsGb28181StreamChannel ch;
ch.set_channel_id(_session_id + "@" + chid); ch.set_channel_id(_session_id + "@" + chid);
@ -226,7 +234,7 @@ srs_error_t SrsGb28181SipSession::do_cycle()
srs_trace("gb28181: %s clients device=%s send invite code=%d", srs_trace("gb28181: %s clients device=%s send invite code=%d",
_session_id.c_str(), chid.c_str(), code); _session_id.c_str(), chid.c_str(), code);
}//end for (it) }//end while (auto_play_list.size())
}//end if (config) }//end if (config)
if (_register_status == SrsGb28181SipSessionRegisterOk && if (_register_status == SrsGb28181SipSessionRegisterOk &&
@ -911,7 +919,7 @@ srs_error_t SrsGb28181SipService::fetch_or_create_sip_session(SrsSipRequest *req
if ((sess = fetch(req->sip_auth_id)) != NULL) { if ((sess = fetch(req->sip_auth_id)) != NULL) {
*sip_session = sess; *sip_session = sess;
return err; return err;
} }
sess = new SrsGb28181SipSession(this, req);; sess = new SrsGb28181SipSession(this, req);;
if ((err = sess->serve()) != srs_success) { if ((err = sess->serve()) != srs_success) {