Commit a1e0e9356d059d54c48fe40a3d899153a251a113
1 parent
58f76d3f
补充sip配置
Showing
4 changed files
with
61 additions
and
17 deletions
src/decoder/gb28181/sip/Message/CatalogParser.cpp
@@ -688,25 +688,28 @@ ServerInfo CCatalogParser::DecodeServerConfig(const char* body) | @@ -688,25 +688,28 @@ ServerInfo CCatalogParser::DecodeServerConfig(const char* body) | ||
688 | { | 688 | { |
689 | info.setSipId(getItemValue(pNode)); | 689 | info.setSipId(getItemValue(pNode)); |
690 | } | 690 | } |
691 | - else if (CGBMessage::CompareNoCase( type, "SipRealm" )) | ||
692 | - { | 691 | + else if (CGBMessage::CompareNoCase( type, "SipRealm" )) { |
693 | info.setSipRealm(getItemValue(pNode)); | 692 | info.setSipRealm(getItemValue(pNode)); |
694 | } | 693 | } |
695 | - else if (CGBMessage::CompareNoCase( type, "Password" )) | ||
696 | - { | 694 | + else if (CGBMessage::CompareNoCase( type, "Password" )) { |
697 | info.setSipPass(getItemValue(pNode)); | 695 | info.setSipPass(getItemValue(pNode)); |
698 | } | 696 | } |
699 | - else if (CGBMessage::CompareNoCase( type, "Timeout" )) | ||
700 | - { | 697 | + else if (CGBMessage::CompareNoCase( type, "Timeout" )) { |
701 | string str = getItemValue(pNode); | 698 | string str = getItemValue(pNode); |
702 | int i = atoi(str.c_str()); | 699 | int i = atoi(str.c_str()); |
703 | info.setTimeout(i); | 700 | info.setTimeout(i); |
704 | - } | ||
705 | - else if (CGBMessage::CompareNoCase( type, "Expiry" )) | ||
706 | - { | 701 | + } else if (CGBMessage::CompareNoCase( type, "Expiry" )) { |
707 | string str = getItemValue(pNode); | 702 | string str = getItemValue(pNode); |
708 | int i = atoi(str.c_str()); | 703 | int i = atoi(str.c_str()); |
709 | info.setExpiry(i); | 704 | info.setExpiry(i); |
705 | + } else if (CGBMessage::CompareNoCase( type, "MinRtpPort" )) { | ||
706 | + string str = getItemValue(pNode); | ||
707 | + int i = atoi(str.c_str()); | ||
708 | + info.setMinRtpPort(i); | ||
709 | + } else if (CGBMessage::CompareNoCase( type, "MaxRtpPort" )) { | ||
710 | + string str = getItemValue(pNode); | ||
711 | + int i = atoi(str.c_str()); | ||
712 | + info.setMaxRtpPort(i); | ||
710 | } | 713 | } |
711 | } | 714 | } |
712 | 715 |
src/decoder/gb28181/sip/SipServer.cpp
@@ -38,7 +38,7 @@ static void timing_getcatlog_thread(void* arg) { | @@ -38,7 +38,7 @@ static void timing_getcatlog_thread(void* arg) { | ||
38 | _this->timing_getcatlog(); | 38 | _this->timing_getcatlog(); |
39 | } | 39 | } |
40 | else { | 40 | else { |
41 | - LOG_ERROR("event_loop线程启动失败 !"); | 41 | + LOG_ERROR("timing_getcatlog 线程启动失败 !"); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
@@ -123,6 +123,14 @@ bool SipServer::Init(ServerInfo* pInfo) { | @@ -123,6 +123,14 @@ bool SipServer::Init(ServerInfo* pInfo) { | ||
123 | return true; | 123 | return true; |
124 | } | 124 | } |
125 | 125 | ||
126 | +int SipServer::GetMinRtpPort(){ | ||
127 | + return mInfo.getMinRtpPort(); | ||
128 | +} | ||
129 | + | ||
130 | +int SipServer::GetMaxRtpPort(){ | ||
131 | + return mInfo.getMaxRtpPort(); | ||
132 | +} | ||
133 | + | ||
126 | int SipServer::sip_event_handle(eXosip_event_t *evtp) { | 134 | int SipServer::sip_event_handle(eXosip_event_t *evtp) { |
127 | 135 | ||
128 | switch(evtp->type) { | 136 | switch(evtp->type) { |
@@ -226,6 +234,8 @@ void SipServer::event_loop() { | @@ -226,6 +234,8 @@ void SipServer::event_loop() { | ||
226 | if(this->init_sip_server() !=0 ){ | 234 | if(this->init_sip_server() !=0 ){ |
227 | return; | 235 | return; |
228 | } | 236 | } |
237 | + | ||
238 | + thread* timing_getcatlog_threadptr = new std::thread(timing_getcatlog_thread, this); | ||
229 | 239 | ||
230 | while(!mQuit) { | 240 | while(!mQuit) { |
231 | eXosip_event_t *evtp = eXosip_event_wait(mSipCtx, 0, 20); | 241 | eXosip_event_t *evtp = eXosip_event_wait(mSipCtx, 0, 20); |
@@ -238,10 +248,24 @@ void SipServer::event_loop() { | @@ -238,10 +248,24 @@ void SipServer::event_loop() { | ||
238 | this->sip_event_handle(evtp); | 248 | this->sip_event_handle(evtp); |
239 | eXosip_event_free(evtp); | 249 | eXosip_event_free(evtp); |
240 | } | 250 | } |
251 | + | ||
252 | + mQuit = true; | ||
253 | + if (timing_getcatlog_threadptr) { | ||
254 | + timing_getcatlog_threadptr->join(); | ||
255 | + delete timing_getcatlog_threadptr; | ||
256 | + timing_getcatlog_threadptr = nullptr; | ||
257 | + } | ||
241 | } | 258 | } |
242 | 259 | ||
243 | -void SipServer::close() { | 260 | +void SipServer::Close() { |
244 | mQuit = true; | 261 | mQuit = true; |
262 | + | ||
263 | + if (m_event_loop_thread) { | ||
264 | + m_event_loop_thread->join(); | ||
265 | + delete m_event_loop_thread; | ||
266 | + m_event_loop_thread = nullptr; | ||
267 | + } | ||
268 | + | ||
245 | } | 269 | } |
246 | 270 | ||
247 | void SipServer::timing_getcatlog() { | 271 | void SipServer::timing_getcatlog() { |
src/decoder/gb28181/sip/SipServer.h
@@ -85,7 +85,11 @@ public: | @@ -85,7 +85,11 @@ public: | ||
85 | 85 | ||
86 | int RequestInvite_TCP_a(const char* dst_channel, int rtpPort); | 86 | int RequestInvite_TCP_a(const char* dst_channel, int rtpPort); |
87 | 87 | ||
88 | - void close(); | 88 | + void Close(); |
89 | + | ||
90 | + int GetMinRtpPort(); | ||
91 | + | ||
92 | + int GetMaxRtpPort(); | ||
89 | 93 | ||
90 | public: | 94 | public: |
91 | void event_loop(); | 95 | void event_loop(); |
@@ -124,7 +128,7 @@ private: | @@ -124,7 +128,7 @@ private: | ||
124 | std::map<std::string, DeviceInfo> m_device_map; | 128 | std::map<std::string, DeviceInfo> m_device_map; |
125 | mutex m_device_map_mtx; | 129 | mutex m_device_map_mtx; |
126 | 130 | ||
127 | - thread* m_event_loop_thread; | 131 | + thread* m_event_loop_thread{nullptr}; |
128 | }; | 132 | }; |
129 | 133 | ||
130 | 134 |
src/decoder/gb28181/sip/sip_header.h
@@ -59,11 +59,10 @@ public: | @@ -59,11 +59,10 @@ public: | ||
59 | ServerInfo() {} | 59 | ServerInfo() {} |
60 | 60 | ||
61 | ServerInfo(string ua,string nonce, string ip, int port, | 61 | ServerInfo(string ua,string nonce, string ip, int port, |
62 | - string sipId, string sipRealm, string sipPass, int sipTimeout, int sipExpiry): | ||
63 | - mUa(ua), | ||
64 | - mNonce(nonce),mIp(ip),mPort(port),mSipId(sipId), | 62 | + string sipId, string sipRealm, string sipPass, int sipTimeout, int sipExpiry, int minRtpPort, int maxRtpPort): |
63 | + mUa(ua),mNonce(nonce),mIp(ip),mPort(port),mSipId(sipId), | ||
65 | mSipRealm(sipRealm),mSipPass(sipPass),mSipTimeout(sipTimeout), | 64 | mSipRealm(sipRealm),mSipPass(sipPass),mSipTimeout(sipTimeout), |
66 | - mSipExpiry(sipExpiry){} | 65 | + mSipExpiry(sipExpiry),mMinRtpPort(minRtpPort),mMaxRtpPort(maxRtpPort){} |
67 | 66 | ||
68 | ~ServerInfo() = default; | 67 | ~ServerInfo() = default; |
69 | public: | 68 | public: |
@@ -122,6 +121,18 @@ public: | @@ -122,6 +121,18 @@ public: | ||
122 | void setExpiry(int i) { | 121 | void setExpiry(int i) { |
123 | mSipExpiry = i; | 122 | mSipExpiry = i; |
124 | } | 123 | } |
124 | + int getMinRtpPort() const { | ||
125 | + return mMinRtpPort; | ||
126 | + } | ||
127 | + void setMinRtpPort(int i) { | ||
128 | + mMinRtpPort = i; | ||
129 | + } | ||
130 | + int getMaxRtpPort() const { | ||
131 | + return mMaxRtpPort; | ||
132 | + } | ||
133 | + void setMaxRtpPort(int i) { | ||
134 | + mMaxRtpPort = i; | ||
135 | + } | ||
125 | 136 | ||
126 | private: | 137 | private: |
127 | string mUa; | 138 | string mUa; |
@@ -133,6 +144,8 @@ private: | @@ -133,6 +144,8 @@ private: | ||
133 | string mSipPass;//SIP password | 144 | string mSipPass;//SIP password |
134 | int mSipTimeout; //SIP timeout | 145 | int mSipTimeout; //SIP timeout |
135 | int mSipExpiry;// SIP到期 | 146 | int mSipExpiry;// SIP到期 |
147 | + int mMinRtpPort; | ||
148 | + int mMaxRtpPort; | ||
136 | }; | 149 | }; |
137 | 150 | ||
138 | 151 |