Skip to content

Commit

Permalink
If an invalid port is specified, don't actually start the rtp threads…
Browse files Browse the repository at this point in the history
…. They don't get used in RTP/RTSP. Fixes #3759
  • Loading branch information
Isaac Connor committed Sep 13, 2024
1 parent 0ac7434 commit 0af4419
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/zm_rtp_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ int RtpCtrlThread::recvPackets( unsigned char *buffer, ssize_t nBytes ) {
}

void RtpCtrlThread::Run() {
if (mRtpSource.getLocalCtrlPort()<=1024) {
Debug(2, "Not starting control thread");
return;
}
Debug( 2, "Starting control thread %x on port %d", mRtpSource.getSsrc(), mRtpSource.getLocalCtrlPort() );
zm::SockAddrInet localAddr, remoteAddr;

Expand Down
9 changes: 7 additions & 2 deletions src/zm_rtp_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ bool RtpDataThread::recvPacket(const unsigned char *packet, size_t packetLen) {
}

void RtpDataThread::Run() {
if (mRtpSource.getLocalDataPort()<=1024) {
Debug(2, "Not starting data thread");
return;
}
Debug(2, "Starting data thread %d on port %d",
mRtpSource.getSsrc(), mRtpSource.getLocalDataPort());

zm::SockAddrInet localAddr;
zm::UdpInetServer rtpDataSocket;
if ( mRtpSource.getLocalHost() != "" ) {
if ( !rtpDataSocket.bind(mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort()) )
Fatal("Failed to bind RTP server");
Fatal("Failed to bind RTP server at %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort());
} else {
if ( !rtpDataSocket.bind(
mRtspThread.getAddressFamily() == AF_INET6 ? "::" : "0.0.0.0",
mRtpSource.getLocalDataPort() ) )
Fatal("Failed to bind RTP server");
Fatal("Failed to bind RTP server at %s:%d",
(mRtspThread.getAddressFamily() == AF_INET6 ? "::" : "0.0.0.0"), mRtpSource.getLocalDataPort());
}
Debug(3, "Bound to %s:%d", mRtpSource.getLocalHost().c_str(), mRtpSource.getLocalDataPort());

Expand Down

0 comments on commit 0af4419

Please sign in to comment.