Conversation
bennylp
requested changes
Jul 18, 2022
bennylp
approved these changes
Jul 19, 2022
nanangizz
approved these changes
Jul 20, 2022
Merged
wosrediinanatour
pushed a commit
to wosrediinanatour/pjproject
that referenced
this pull request
Jan 16, 2023
BarryYin
pushed a commit
to BarryYin/pjproject
that referenced
this pull request
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Steps to add UPnP support:
libupnp-devlibupnpfrom https://github.com/pupnp/pupnplibupnpby following the instructions. Check the build note below for some recommendations.checking UPnP usability... yespjsua_config.enable_upnporUaConfig::enableUpnp.Build recommendation for
libupnp:By default,
libupnpsend its requests using blocking sockets. This may cause long timeout delay (in our test, it can take more than 1 minute) if your router/IGD (Internet Gateway Device) suddenly goes offline or in the network disconnection scenario. To overcome this, enable non-blocking option for the sockets by configuringlibupnpwith:./configure --disable-blocking_tcp_connections [--enable-debug](
--enable-debugis used to get debugging info and enable logging).Next, even though the socket is now non-blocking, the default timeout set by
libupnpis also quite long (30 secs). Unfortunately, the timeout is not configurable, so you may need to modify it directly in the following files:upnp/src/inc/httpreadwrite.h:changeHTTP_DEFAULT_TIMEOUT(default 30 secs)upnp/src/inc/upnpapi.h: changeUPNP_TIMEOUT(default 30 secs)Build instructions for Windows:
cmake -DDOWNLOAD_AND_BUILD_DEPS=ONto download buildpthreads-win32dependency as well. Open the generated VS solution and buildlibupnp.#define PJNATH_HAS_UPNP 1in yourconfig_site.h.UPNP_STATIC_LIBinpjnathproject property as well. You will need three libraries:libpthread,libupnp, andlibixml.__imp_*not found. For some reason, the generated VS projects generated bycmakeabove use an incorrect compilation flag. The solution is to changeProperties-C/C++-Code Generation-Runtime LibraryfromMulti-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd). Then rebuild everything.strcpy_sorstrcat_s.libupnpoverwrites standard string functions in order to use the secure version inixml/inc/posix_overwrites.h, such as#define strcat(arg1, arg2) strcat_s(arg1, sizeof(arg1), arg2). Unfortunately, this doesn't work ifarg1is of typechar *(instead ofchar[]). The workaround is to comment these redefinitions. Then rebuild all and ignore all the unsafe string warnings thrown out by VS.Known limitation:
libupnpinitialisation functionUpnpInit2()expects an interface name as its parameter, however currently there's no PJSIP API to get the interface name.pj_enum_ip_interface()will only enumerate the interface addresses. The parameter is optional though, so passingNULLand letlibupnpfind the first suitable interface for you should probably work in most circumstances.Tested with
libupnp1.14.x.