Commit 7d529db7143a8f64098ded6351d397986738b11b
1 parent
6c1a5cc0
修复端口分配问题
Showing
2 changed files
with
9 additions
and
4 deletions
src/decoder/gb28181/rtp2/RTPReceiver2.cpp
... | ... | @@ -56,7 +56,7 @@ void RTPReceiver2::SetVodEndCallback(CallBack_VodFileEnd cb, void* param) |
56 | 56 | bool RTPReceiver2::Open(string channel_id, bool isUdp) { |
57 | 57 | m_SipChannelId = channel_id; |
58 | 58 | |
59 | - m_rtp_port = allocRtpPort(); | |
59 | + m_rtp_port = allocRtpPort(isUdp); | |
60 | 60 | if (m_rtp_port < 0) { |
61 | 61 | return false; |
62 | 62 | } |
... | ... | @@ -313,7 +313,7 @@ void RTPReceiver2::parseTcpData(uint8_t* recvBuf, int recvBufSize) { |
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | -int RTPReceiver2::allocRtpPort() { | |
316 | +int RTPReceiver2::allocRtpPort(bool isUdp) { | |
317 | 317 | |
318 | 318 | WebsocketClient* pServer = WebsocketClient::getInstance(); |
319 | 319 | int MIN_RTP_PORT = pServer->GetMinRtpPort() ; |
... | ... | @@ -342,7 +342,12 @@ int RTPReceiver2::allocRtpPort() { |
342 | 342 | int i = 0; |
343 | 343 | for (; i < 2; i++) { |
344 | 344 | sockaddr_in sRecvAddr; |
345 | - int s = socket(AF_INET, SOCK_DGRAM, 0); | |
345 | + int s = -1; | |
346 | + if (isUdp) { | |
347 | + s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); | |
348 | + } else { | |
349 | + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | |
350 | + } | |
346 | 351 | |
347 | 352 | sRecvAddr.sin_family = AF_INET; |
348 | 353 | sRecvAddr.sin_addr.s_addr = htonl(INADDR_ANY); | ... | ... |