### Build with Meson Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md Utilize Meson for building the project across different platforms. This includes setup, compilation, testing, and installation steps. ```bash # Setup the build subdirectory meson setup --prefix=/path/to/prefix builddir ``` ```bash # Build the project meson compile -C builddir ``` ```bash # Run tests meson test -C builddir ``` ```bash # Optionally, install meson install -C builddir ``` -------------------------------- ### Basic libSRTP Usage Example Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md This example shows how to initialize libSRTP, set up a security policy with default RTP and RTCP crypto policies, and create an SRTP session. It then enters a loop to get RTP packets, protect them using SRTP, and send the protected packets. Assumes availability of get_rtp_packet() and send_srtp_packet() functions. ```c srtp_t session; srtp_policy_t policy; // Set key to predetermined value uint8_t key[30] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D}; // initialize libSRTP srtp_init(); // default policy values memset(&policy, 0x0, sizeof(srtp_policy_t)); // set policy to describe a policy for an SRTP stream srtp_crypto_policy_set_rtp_default(&policy.rtp); srtp_crypto_policy_set_rtcp_default(&policy.rtcp); policy.ssrc = ssrc; policy.key = key; policy.next = NULL; // allocate and initialize the SRTP session srtp_create(&session, &policy); // main loop: get rtp packets, send srtp packets while (1) { char rtp_buffer[2048]; unsigned len; len = get_rtp_packet(rtp_buffer); srtp_protect(session, rtp_buffer, &len); send_srtp_packet(rtp_buffer, len); } ``` -------------------------------- ### PJSIP/PJPROJECT Logging Example Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md Illustrates the syntax for logging messages within PJSIP/PJPROJECT. Note the double parentheses required for the logging macro. ```c PJ_LOG(level, (sender, format, ...)) ``` -------------------------------- ### PJSIP/PJPROJECT Configure Options Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md Examples of common configure options for PJSIP/PJPROJECT. These options modify build behavior, such as enabling shared libraries or switching SSL backends. ```bash --with-gnutls=/usr/ ``` ```bash --disable-ssl ``` ```bash --enable-shared ``` -------------------------------- ### Configure Android SDK and NDK Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Installs necessary Android SDK components like NDK, CMake, and build tools. Ensure ANDROID_SDK_ROOT is set correctly. ```bash export ANDROID_SDK_ROOT=/somewhere/there/is/installed/the/sdk/ sdkmanager --install "ndk;28.0.12674087" --channel=3 --sdk_root=$ANDROID_SDK_ROOT sdkmanager --install "cmake;3.31.0" --sdk_root=$ANDROID_SDK_ROOT sdkmanager --install "build-tools;35.0.0" "platform-tools" "platforms;android-35" --sdk_root=$ANDROID_SDK_ROOT echo yes | sdkmanager --licenses --sdk_root=$ANDROID_SDK_ROOT ``` -------------------------------- ### SRTP Session Example with rtpw Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md Demonstrates an SRTP session using two 'rtpw' instances, one as a sender and one as a receiver, with specified encryption and authentication settings. ```bash set k=c1eec3717da76195bb878578790af71c4ee9f859e197a414a78d5abc7451 [sh1]$ test/rtpw -s -k $k -e 128 -a 0.0.0.0 9999 Security services: confidentiality message authentication set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 setting SSRC to 2078917053 sending word: A sending word: a sending word: aa sending word: aal ... [sh2]$ test/rtpw -r -k $k -e 128 -a 0.0.0.0 9999 security services: confidentiality message authentication set master key/salt to C1EEC3717DA76195BB878578790AF71C/4EE9F859E197A414A78D5ABC7451 19 octets received from SSRC 2078917053 word: A 19 octets received from SSRC 2078917053 word: a 20 octets received from SSRC 2078917053 word: aa 21 octets received from SSRC 2078917053 word: aal ... ``` -------------------------------- ### Rebuild Configure Script with Automake Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md On macOS, use Homebrew to install automake and pkgconfig. After editing 'configure.in', run 'autoremake' to rebuild the configure script. ```bash brew install automake pkgconfig # Edit configure.in autoremake -ivf ``` -------------------------------- ### Install Git inside Docker Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Updates the package list and installs the Git version control system within the Docker container. ```bash $ sudo apt-update $ sudo apt-get install git ``` -------------------------------- ### Pull and Run Ubuntu Docker Image Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Pulls the Ubuntu Docker image and starts an interactive terminal session. All subsequent commands should be run inside this container. ```bash $ docker pull ubuntu $ docker run -it ubuntu ``` -------------------------------- ### Set Android NDK Root Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Defines the ANDROID_NDK_ROOT environment variable, pointing to your NDK installation. ```bash export ANDROID_NDK_ROOT=/path/to/ndk/root/installation ``` -------------------------------- ### Build and Test PJSIP/PJPROJECT Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md Standard commands for configuring, building, and cleaning the PJSIP/PJPROJECT library. Ensure to run 'make clean' when switching SSL backends or configure options. ```bash ./configure && make -j3 ``` ```bash find . -name "*.depend" -delete && make ``` ```bash cd pjlib/build && make ``` ```bash make clean ``` ```bash make infotarget ``` -------------------------------- ### Configure SRTP Include Directories and Definitions Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/CMakeLists.txt Sets up include directories and compile definitions for the SRTP target, including a custom build directory and configuration header. ```cmake target_include_directories(srtp BEFORE PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../build/srtp" ) target_compile_definitions(srtp PRIVATE HAVE_CONFIG_H=1) ``` -------------------------------- ### Configure iOS PJSIP Build Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Sets up the PJSIP build for iOS simulator, including minimum iOS version and architecture flags. ```c #define PJ_CONFIG_IPHONE 1 #include ``` ```bash export DEVPATH="`xcrun -sdk iphonesimulator --show-sdk-platform-path`/Developer" MIN_IOS="-miphoneos-version-min=12.2" ARCH="-arch x86_64" CFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" LDFLAGS="-O2 -m32 -mios-simulator-version-min=12.2 -fembed-bitcode" ./configure-iphone ``` -------------------------------- ### Configure libSRTP Build Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md Run the configure script with various options to customize the libSRTP build. Options include enabling debug logging, specific crypto engines like OpenSSL or NSS, and directing log output. ```bash ./configure [ options ] make ``` -------------------------------- ### Build PJSIP C# SWIG Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Builds the C# SWIG interface for PJSIP. ```bash make ``` -------------------------------- ### Build PJSIP for Android Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Builds the PJSIP library for Android after configuration. ```bash make dep && make clean && make ``` -------------------------------- ### Configure PJSIP for Android Simulator Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Configures PJSIP build for an Android simulator, specifying the target ABI. ```bash TARGET_ABI=x86_64 ./configure-android ``` -------------------------------- ### Run Fuzz Tests Source: https://github.com/pjsip/pjproject/blob/master/FUZZING.MD Execute the fuzzing tests by navigating to the fuzzing directory, creating a coverage directory, unzipping the seed corpus, and running the fuzz binary. This command initiates the fuzzing process with the specified coverage directory and seed corpus. ```bash cd tests/fuzz mkdir cov-json unzip seed/fuzz-json_seed_corpus.zip ./fuzz-json cov-json/ fuzz-json_seed_corpus/ ``` -------------------------------- ### Configure PJSIP for Android Device Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Configures PJSIP build for a physical Android device. ```bash ./configure-android ``` -------------------------------- ### Run .NET MAUI iOS App on Simulator Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Restores workloads and dependencies, then builds and runs the .NET MAUI iOS application on a simulator. ```bash dotnet workload restore dotnet restore dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_EMULATOR ``` -------------------------------- ### Include Raw Assets in MAUI Project Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/Resources/Raw/AboutAssets.txt Add this line to your .csproj file to include all files in the Resources\Raw directory and its subdirectories as MauiAssets. The LogicalName ensures they are deployed with the correct relative path. ```xml ``` -------------------------------- ### Run Specific PJSIP/PJPROJECT Test Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md Execute a specific test case for a PJSIP/PJPROJECT module. This must be run from the 'bin/' directory. ```bash cd pjlib/bin && ./pjlib-test-x86_64-pc-linux-gnu timer_test ``` ```bash cd pjlib/bin && ./pjlib-test-x86_64-pc-linux-gnu --list ``` -------------------------------- ### Run PJSIP/PJPROJECT Tests Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md Commands to execute various test suites for PJSIP/PJPROJECT modules. These tests can take a significant amount of time and should not be cancelled. ```bash make pjlib-test ``` ```bash make pjsip-test ``` ```bash make pjsua-test ``` -------------------------------- ### Build pffft on ARM with GCC Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc_aec3/src/third_party/pffft/README.txt Compile pffft on an ARM architecture using GCC with specific optimization flags. Ensure fftpack.c and the math library are linked. ```bash gcc -O3 -march=armv7-a -mtune=native -mfloat-abi=hard -mfpu=neon -ffast-math test_pffft.c pffft.c -o test_pffft_arm fftpack.c -lm ``` -------------------------------- ### Run .NET MAUI Android App Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Restores workloads and dependencies, then builds and runs the .NET MAUI Android application. ```bash dotnet workload restore dotnet restore dotnet build -t:Run -c Debug -f net9.0-android ``` -------------------------------- ### Run .NET MAUI iOS App on Device Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Restores workloads and dependencies, then builds and runs the .NET MAUI iOS application on a connected device. ```bash dotnet workload restore dotnet restore dotnet build -t:Run -c Debug -f net9.0-ios -p:_DeviceName=:v2:udid=UDID_OF_YOUR_DEVICE ``` -------------------------------- ### Configure Resample Headers Source: https://github.com/pjsip/pjproject/blob/master/third_party/resample/CMakeLists.txt Sets up the header files for the resample library, making them available for inclusion. It specifies the base directory and the header files themselves. ```cmake target_sources(resample PUBLIC FILE_SET HEADERS BASE_DIRS include FILES include/resamplesubs.h ) ``` -------------------------------- ### Configure PJSIP for iOS Device Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Configures PJSIP build for a physical iOS device. ```bash ./configure-iphone ``` -------------------------------- ### Build with CMake for Visual Studio Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md Use CMake to generate Visual Studio project files. Specify the generator for the desired Visual Studio version and architecture. ```bash cmake .. -G "Visual Studio 15 2017" ``` ```bash cmake .. -G "Visual Studio 15 2017 Win64" ``` -------------------------------- ### Include NEON SIMD Audio Processing Sources Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc/CMakeLists.txt Adds NEON-optimized C source files for audio processing modules when WEBRTC_ARCH_SIMD is set to 'neon'. ```cmake if(WEBRTC_ARCH_SIMD STREQUAL "neon") target_sources(webrtc PRIVATE src/webrtc/modules/audio_processing/aec/aec_core_neon.c src/webrtc/modules/audio_processing/aec/aec_rdft_neon.c src/webrtc/modules/audio_processing/aecm/aecm_core_c.c src/webrtc/modules/audio_processing/aecm/aecm_core_neon.c src/webrtc/modules/audio_processing/ns/nsx_core_c.c src/webrtc/modules/audio_processing/ns/nsx_core_neon.c src/webrtc/common_audio/signal_processing/cross_correlation_neon.c src/webrtc/common_audio/signal_processing/downsample_fast_neon.c src/webrtc/common_audio/signal_processing/min_max_operations_neon.c ) ``` -------------------------------- ### Find and Link Math Library (CMake) Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc/CMakeLists.txt Locates the math library and links it to the 'webrtc' target. This is typically used on non-Windows systems. ```cmake if (NOT (WIN32 OR CYGWIN OR MINGW)) # math library find_library(MATH_LIBRARY m REQUIRED) target_link_libraries(webrtc PRIVATE "${MATH_LIBRARY}") endif() ``` -------------------------------- ### Run Coverity Scan Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Executes the Coverity Scan script for the PJSIP project. Use '-t' to skip uploading results or '-h' for help. ```bash $ cd pjproject $ tests/coverity-scan/run.sh ``` -------------------------------- ### Access MAUI App Package File Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/Resources/Raw/AboutAssets.txt This C# code demonstrates how to open and read the contents of a raw asset file deployed with your MAUI application. Ensure the asset is included using the MauiAsset build action. ```csharp async Task LoadMauiAsset() { using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); using var reader = new StreamReader(stream); var contents = reader.ReadToEnd(); } ``` -------------------------------- ### Set Export Flags for Fuzzing Source: https://github.com/pjsip/pjproject/blob/master/FUZZING.MD Configure environment variables for the build process, including the C/C++ compiler and fuzzing engine. Ensure the correct sanitizers and optimization flags are set for production-unsafe builds. ```bash export CC=clang export CXX=clang++ export LIB_FUZZING_ENGINE=-fsanitize=fuzzer export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link" export CXXFLAGS="$CFLAGS" export LDFLAGS="$CFLAGS" ``` -------------------------------- ### Generate Visual Studio Build Files with CMake Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/README.md On Windows, use CMake to create Visual Studio build files. This involves creating a 'build' subdirectory and running CMake commands within it. ```bash # Create build subdirectory mkdir build cd build ``` -------------------------------- ### Include MIPS SIMD Audio Processing Sources Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc/CMakeLists.txt Adds MIPS-optimized C source files for audio processing modules when WEBRTC_ARCH_SIMD is set to 'mips'. ```cmake elseif(WEBRTC_ARCH_SIMD STREQUAL "mips") target_sources(webrtc PRIVATE src/webrtc/modules/audio_processing/aec/aec_core_mips.c src/webrtc/modules/audio_processing/aec/aec_rdft_mips.c src/webrtc/modules/audio_processing/aecm/aecm_core_mips.c src/webrtc/modules/audio_processing/ns/nsx_core_mips.c src/webrtc/common_audio/signal_processing/cross_correlation_mips.c src/webrtc/common_audio/signal_processing/downsample_fast_mips.c src/webrtc/common_audio/signal_processing/min_max_operations_mips.c ) ``` -------------------------------- ### Link C Consumer to Pj::pjsua-lib Source: https://github.com/pjsip/pjproject/blob/master/tests/cmake/CMakeLists.txt Create a C executable target and link it against `Pj::pjsua-lib`. This is used for consuming the C API of pjsua-lib and its dependency chain. ```cmake # C consumer: exercise pjsua-lib (C API) and the full dependency chain # (pjsua-lib -> pjsip -> pjmedia -> Pj::Dep::SRTP etc.) add_executable(test_consumer test_consumer.c) target_link_libraries(test_consumer PRIVATE Pj::pjsua-lib) ``` -------------------------------- ### Include SSE2 SIMD Audio Processing Sources Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc/CMakeLists.txt Adds SSE2-optimized C source files and CPU features detection for audio processing modules when WEBRTC_ARCH_SIMD is set to 'sse2'. ```cmake elseif(WEBRTC_ARCH_SIMD STREQUAL "sse2") target_sources(webrtc PRIVATE src/webrtc/modules/audio_processing/aec/aec_core_sse2.c src/webrtc/modules/audio_processing/aec/aec_rdft_sse2.c src/webrtc/modules/audio_processing/aecm/aecm_core_c.c src/webrtc/modules/audio_processing/ns/nsx_core_c.c src/webrtc/system_wrappers/source/cpu_features.cc ) ``` -------------------------------- ### Publish .NET MAUI iOS App Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2maui/README.md Publishes the .NET MAUI iOS application for deployment, generating an .ipa file. ```bash dotnet publish -c Debug -f net9.0-ios -p:RuntimeIdentifier=ios-arm64 ``` -------------------------------- ### External SRTP Configuration Source: https://github.com/pjsip/pjproject/blob/master/pjmedia/CMakeLists.txt Configures pjmedia to use external SRTP library, retrieving version and feature information if SRTP is enabled and provided by the system. ```cmake if(PJMEDIA_WITH_SRTP) get_target_property(srtp_provider Pj::Dep::SRTP PJ_DEP_PROVIDER) if(srtp_provider STREQUAL "system") get_target_property(srtp_version_major Pj::Dep::SRTP SRTP_VERSION_MAJOR) get_target_property(srtp_has_deinit Pj::Dep::SRTP SRTP_HAS_DEINIT) get_target_property(srtp_has_shutdown Pj::Dep::SRTP SRTP_HAS_SHUTDOWN) target_compile_definitions(pjmedia PRIVATE PJMEDIA_EXTERNAL_SRTP=${srtp_version_major} PJMEDIA_SRTP_HAS_DEINIT=${srtp_has_deinit} PJMEDIA_SRTP_HAS_SHUTDOWN=${srtp_has_shutdown} ) endif() endif() ``` -------------------------------- ### Include Default C Audio Processing Sources Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc/CMakeLists.txt Adds standard C source files for audio processing modules when no specific SIMD architecture is detected or configured. ```cmake else() target_sources(webrtc PRIVATE src/webrtc/modules/audio_processing/aecm/aecm_core_c.c src/webrtc/modules/audio_processing/ns/nsx_core_c.c src/webrtc/common_audio/signal_processing/complex_fft.c ) endif() ``` -------------------------------- ### Detect Architecture and Set Compile Definitions Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This snippet detects the host architecture and sets corresponding PJ_M_* macros as compile definitions. It includes support for various architectures like x86_64, ARM64, and others. ```cmake block(SCOPE_FOR_VARIABLES) include(Pj/DetectArch) pj_detect_arch(arch) # architecture name set(PJ_M_NAME "${arch}") # architecture macros target_compile_definitions(pjlib PUBLIC $<$:PJ_M_I386=1> $<$:PJ_M_X86_64=1> $<$:PJ_M_IA64=1> $<$:PJ_M_M68K=1> $<$:PJ_M_ALPHA=1> $<$:PJ_M_MIPS=1> $<$:PJ_M_MIPS=1> $<$:PJ_M_SPARC=1> $<$:PJ_M_ARM64=1> $<$:PJ_M_ARMV7=1> $<$:PJ_M_ARMV4=1> $<$:PJ_M_POWERPC=1> $<$:PJ_M_NIOS2=1> ) # endianness detection include(TestBigEndian) test_big_endian(WORDS_BIGENDIAN) # floating point support if(PJLIB_WITH_FLOATING_POINT) set(PJ_HAS_FLOATING_POINT 1) else() set(PJ_HAS_FLOATING_POINT 0) endif() # write configured header configure_file( include/pj/compat/m_auto.h.cm include/pj/compat/m_auto.h @ONLY ) endblock() ``` -------------------------------- ### Accessing Raw Assets Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2xamarin/pjsua2xamarin.Android/Assets/AboutAssets.txt Use `Assets.Open()` to access raw asset files deployed with your application. Ensure the asset file has a 'AndroidAsset' build action. ```csharp public class ReadAsset : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); InputStream input = Assets.Open ("my_asset.txt"); } } ``` -------------------------------- ### PJSIP/PJPROJECT Quick Smoke Test Source: https://github.com/pjsip/pjproject/blob/master/CLAUDE.md A quick smoke test for PJSIP/PJPROJECT using Python. This command initiates a basic test run for the PJSUA application. ```bash cd tests/pjsua && python3 run.py mod_run.py scripts-run/100_simple.py ``` -------------------------------- ### Add pjsua2-test Executable Source: https://github.com/pjsip/pjproject/blob/master/pjsip/CMakeLists.txt Defines the pjsua2-test executable and links it with required pjsip libraries for general testing. ```cmake add_executable(pjsua2-test src/pjsua2-test/main.cpp src/pjsua2-test/instant_messaging.cpp src/pjsua2-test/auth_challenge.cpp ) target_link_libraries(pjsua2-test PRIVATE pjlib pjlib-util pjnath pjmedia pjmedia-audiodev pjmedia-videodev pjsip pjsip-simple pjsip-ua pjsua-lib pjsua2 ) add_test(NAME pjsua2-test COMMAND pjsua2-test) ``` -------------------------------- ### Check for System Functions Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt Uses check_symbol_exists to verify the availability of various system functions like localtime_r, getifaddrs, inet_aton, inet_pton, inet_ntop, getaddrinfo, and socketpair. ```cmake include(CheckSymbolExists) check_symbol_exists(localtime_r time.h PJ_HAS_LOCALTIME_R) check_symbol_exists(getifaddrs ifaddrs.h PJ_HAS_IFADDRS_H) check_symbol_exists(inet_aton arpa/inet.h PJ_SOCK_HAS_INET_ATON) check_symbol_exists(inet_pton arpa/inet.h PJ_SOCK_HAS_INET_PTON) check_symbol_exists(inet_ntop arpa/inet.h PJ_SOCK_HAS_INET_NTOP) check_symbol_exists(getaddrinfo netdb.h PJ_SOCK_HAS_GETADDRINFO) check_symbol_exists(socketpair sys/socket.h PJ_SOCK_HAS_SOCKETPAIR) ``` -------------------------------- ### Configure SSL Socket Support Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This configures PJ_HAS_SSL_SOCK and PJ_SSL_SOCK_IMP based on the PJLIB_WITH_SSL CMake variable, enabling or disabling SSL socket support and selecting the implementation. ```cmake if(NOT PJLIB_WITH_SSL STREQUAL "") set(PJ_HAS_SSL_SOCK 1) string(TOUPPER "PJ_SSL_SOCK_IMP_${PJLIB_WITH_SSL}" PJ_SSL_SOCK_IMP) else() set(PJ_HAS_SSL_SOCK 0) set(PJ_SSL_SOCK_IMP "PJ_SSL_SOCK_IMP_NONE") endif() ``` -------------------------------- ### Link C++ Consumer to Pj::pjsua2 Source: https://github.com/pjsip/pjproject/blob/master/tests/cmake/CMakeLists.txt Create a C++ executable target and link it against `Pj::pjsua2`. This is used for consuming the C++ API of pjsua2 and its transitive dependencies. ```cmake # C++ consumer: exercise pjsua2 (C++ API) and transitive dependencies add_executable(test_consumer2 test_consumer2.cpp) target_link_libraries(test_consumer2 PRIVATE Pj::pjsua2) ``` -------------------------------- ### Compile PJSIP Fuzzing Suite Source: https://github.com/pjsip/pjproject/blob/master/FUZZING.MD Configure and compile the PJSIP project for fuzzing. It is recommended to disable specific libraries like ffmpeg, ssl, and various codecs to streamline the fuzzing process. Use 'make dep' to fetch dependencies and 'make -j$(nproc)' for parallel compilation. ```bash ./configure --disable-ffmpeg --disable-ssl --disable-speex-aec --disable-speex-codec --disable-g7221-codec --disable-gsm-codec --disable-ilbc-codec --disable-resample --disable-libsrtp --disable-libwebrtc --disable-libyuv make dep make -j$(nproc) make fuzz ``` -------------------------------- ### Configure I/O Queue Implementation Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This sets the PJ_IOQUEUE_IMP variable based on the PJLIB_WITH_IOQUEUE CMake variable, determining the I/O queue implementation to be used. ```cmake if(NOT PJLIB_WITH_IOQUEUE STREQUAL "") string(TOUPPER "PJ_IOQUEUE_IMP_${PJLIB_WITH_IOQUEUE}" PJ_IOQUEUE_IMP) else() set(PJ_IOQUEUE_IMP "PJ_IOQUEUE_IMP_NONE") endif() ``` -------------------------------- ### Add pjsua-stress Executable Source: https://github.com/pjsip/pjproject/blob/master/pjsip/CMakeLists.txt Defines the pjsua-stress executable and links it with required pjsip libraries for stress testing. ```cmake add_executable(pjsua-stress src/test/pjsua_stress.c ) target_link_libraries(pjsua-stress PRIVATE pjlib pjlib-util pjnath pjmedia pjmedia-codec pjmedia-audiodev pjmedia-videodev pjsip pjsip-simple pjsip-ua pjsua-lib ) ``` -------------------------------- ### Link Math Library on Non-Windows Systems Source: https://github.com/pjsip/pjproject/blob/master/third_party/webrtc_aec3/CMakeLists.txt Links the math library 'm' on systems that are not Windows, Cygwin, or MinGW. This is a common requirement for C/C++ projects needing mathematical functions. ```cmake if (NOT (WIN32 OR CYGWIN OR MINGW)) # math library find_library(MATH_LIBRARY m REQUIRED) target_link_libraries(webrtc_aec3 PRIVATE "${MATH_LIBRARY}") elseif(NOT CMAKE_SYSTEM_NAME MATCHES "Windows(Store|Phone)") target_link_libraries(webrtc_aec3 PRIVATE winmm) endif() ``` -------------------------------- ### Create Resample Library Source: https://github.com/pjsip/pjproject/blob/master/third_party/resample/CMakeLists.txt Defines the resample library using source files. This is the primary target for the resample module. ```cmake add_library(resample src/resamplesubs.c) ``` -------------------------------- ### Checkout Coverity Branch Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Switches the local PJSIP repository to the 'coverity01' branch for the scan. ```bash $ git checkout coverity01 ``` -------------------------------- ### Check if IPV6_V6ONLY is available Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt Compiles a C program to check for the availability of the IPV6_V6ONLY socket option, setting PJ_SOCK_HAS_IPV6_V6ONLY if found. ```cmake # determine if IPV6_V6ONLY is available check_source_compiles(C [=[ #include #include int main(void) { int opt = IPV6_V6ONLY; return 0; } ]=] PJ_SOCK_HAS_IPV6_V6ONLY) ``` -------------------------------- ### Configure G711 Codec Definition Source: https://github.com/pjsip/pjproject/blob/master/pjmedia/CMakeLists.txt Sets the PJMEDIA_HAS_G711_CODEC variable based on PJMEDIA_WITH_G711_CODEC to enable or disable the G711 codec. ```cmake block(SCOPE_FOR_VARIABLES) # G711 codec set(PJMEDIA_HAS_G711_CODEC ${PJMEDIA_WITH_G711_CODEC}) # write configured header configure_file( include/pjmedia/config_auto.h.cm include/pjmedia/config_auto.h ) endblock() ``` -------------------------------- ### Configure SRTP with OpenSSL Option Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/CMakeLists.txt Enables or disables OpenSSL support for SRTP. If enabled, it attempts to find OpenSSL and checks for GCM support. ```cmake option(SRTP_WITH_OPENSSL "Build SRTP with OpenSSL support" ON) if(SRTP_WITH_OPENSSL) find_package(OpenSSL COMPONENTS Crypto SSL CONFIG) if(NOT OPENSSL_FOUND) find_package(OpenSSL COMPONENTS Crypto SSL) endif() if(OPENSSL_FOUND) # check GCM support include(CheckCSourceCompiles) include(CMakePushCheckState) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_CRYPTO_LIBRARIES}") check_c_source_compiles([=[ #include int main(void) { EVP_CIPHER_CTX *ctx; EVP_aes_128_gcm(); return 0; } ]=] OPENSSL_HAS_GCM) cmake_pop_check_state() else() set(SRTP_WITH_OPENSSL OFF CACHE BOOL "OpenSSL not found" FORCE) endif() endif() ``` -------------------------------- ### Set Resample Interface Include Directories Source: https://github.com/pjsip/pjproject/blob/master/third_party/resample/CMakeLists.txt Configures the interface include directories for the resample library. This allows build targets that link to resample to find its headers. ```cmake target_include_directories(resample INTERFACE $ ) ``` -------------------------------- ### Set Coverity Scan Token Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Exports the Coverity Scan authorization token as an environment variable. Replace '....' with your actual token. ```bash $ export COV_TOKEN=.... ``` -------------------------------- ### Configure Resample Private Include Directories Source: https://github.com/pjsip/pjproject/blob/master/third_party/resample/CMakeLists.txt Sets the private include directories for the resample library. These are used internally by the resample build process. ```cmake target_include_directories(resample BEFORE PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../build/resample" ) ``` -------------------------------- ### Build pjmedia Test Application Source: https://github.com/pjsip/pjproject/blob/master/pjmedia/CMakeLists.txt Conditionally builds the pjmedia-test executable if testing is enabled. Links against core pjproject libraries. ```cmake if(BUILD_TESTING) add_executable(pjmedia-test src/test/codec_vectors.c src/test/jbuf_test.c src/test/main.c src/test/mips_test.c src/test/vid_codec_test.c src/test/vid_dev_test.c src/test/vid_port_test.c src/test/rtp_test.c src/test/test.c src/test/tone_detector_test.c src/test/sdp_neg_test.c ) target_link_libraries(pjmedia-test PRIVATE pjlib pjlib-util pjnath pjmedia pjmedia-codec pjmedia-audiodev pjmedia-videodev ) add_test(NAME pjmedia-test COMMAND pjmedia-test) endif() ``` -------------------------------- ### Clone PJSIP Repository Source: https://github.com/pjsip/pjproject/blob/master/tests/coverity-scan/README.md Clones the PJSIP project repository from GitHub into the current directory within the Docker container. ```bash $ cd $ git clone https://github.com/pjsip/pjproject.git ``` -------------------------------- ### Loading Fonts from Assets Source: https://github.com/pjsip/pjproject/blob/master/pjsip-apps/src/swig/csharp/pjsua2xamarin/pjsua2xamarin.Android/Assets/AboutAssets.txt Android functions like `Typeface.CreateFromAsset` can directly load font files from the assets folder. Specify the path relative to the assets directory. ```csharp Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); ``` -------------------------------- ### pjmedia Compile Definitions Source: https://github.com/pjsip/pjproject/blob/master/pjmedia/CMakeLists.txt Sets compile definitions for pjmedia based on build configurations for features like SRTP, resampling, AEC, and video support. ```cmake target_compile_definitions(pjmedia PUBLIC # srtp PJMEDIA_HAS_SRTP=$ # resampling backend PJMEDIA_RESAMPLE_IMP=PJMEDIA_RESAMPLE_$ # aec PJMEDIA_HAS_SPEEX_AEC=$ PJMEDIA_HAS_LIBWEBRTC=$ PJMEDIA_WEBRTC_AEC_USE_MOBILE=$,$> PJMEDIA_HAS_LIBWEBRTC_AEC3=$ # video PJMEDIA_HAS_VIDEO=$ PJMEDIA_HAS_LIBYUV=$ PJMEDIA_HAS_FFMPEG=$ PJMEDIA_HAS_LIBAVUTIL=$ PJMEDIA_HAS_LIBSWSCALE=$ PJMEDIA_HAS_LIBAVCODEC=$ PJMEDIA_HAS_LIBAVFORMAT=$ PJMEDIA_HAS_LIBAVDEVICE=$ ) ``` -------------------------------- ### Write Configured Header File Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This command writes the configured header file 'os_auto.h' based on the settings determined during the CMake configuration process. ```cmake configure_file( include/pj/compat/os_auto.h.cm include/pj/compat/os_auto.h @ONLY ) ``` -------------------------------- ### Create Symbolic Link for Headers Source: https://github.com/pjsip/pjproject/blob/master/third_party/resample/CMakeLists.txt Creates a symbolic link to allow inclusion using a specific path structure. This is a workaround for a known path issue. ```cmake file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/include/resamplesubs.h" "${CMAKE_CURRENT_BINARY_DIR}/include/third_party/resample/include/resamplesubs.h" SYMBOLIC COPY_ON_ERROR ) ``` -------------------------------- ### Check if socklen_t is available Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt Compiles a C program to check for the availability of the socklen_t type, setting PJ_HAS_SOCKLEN_T if found. ```cmake # determine if socklen_t is available check_source_compiles(C [=[ #include #include int main(void) { socklen_t xxx = 0; return 0; } ]=] PJ_HAS_SOCKLEN_T) ``` -------------------------------- ### Link SRTP with pjlib and OpenSSL Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/CMakeLists.txt Links the SRTP library against pjlib for logging and conditionally against OpenSSL libraries if enabled. ```cmake # pjlib - for log overrides target_link_libraries(srtp PRIVATE pjlib) # OpenSSL if(SRTP_WITH_OPENSSL AND OPENSSL_HAS_GCM) target_link_libraries(srtp PRIVATE OpenSSL::Crypto OpenSSL::SSL) target_compile_definitions(srtp PRIVATE OPENSSL=1 GCM=1) endif() ``` -------------------------------- ### Check for Standard Header Files Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt Uses CMake's check_include_file to determine the availability of various standard C header files, setting corresponding PJ_HAS_* variables. ```cmake check_include_file(arpa/inet.h PJ_HAS_ARPA_INET_H) check_include_file(assert.h PJ_HAS_ASSERT_H) check_include_file(ctype.h PJ_HAS_CTYPE_H) if(WIN32 OR CYGWIN OR MINGW) set(PJ_HAS_ERRNO_H 0) else() check_include_file(errno.h PJ_HAS_ERRNO_H) endif() check_include_file(fcntl.h PJ_HAS_FCNTL_H) check_include_file(ifaddrs.h PJ_HAS_IFADDRS_H) check_include_file(limits.h PJ_HAS_LIMITS_H) check_include_file(linux/socket.h PJ_HAS_LINUX_SOCKET_H) check_include_file(malloc.h PJ_HAS_MALLOC_H) check_include_file(netdb.h PJ_HAS_NETDB_H) check_include_file(netinet/in_systm.h PJ_HAS_NETINET_IN_SYSTM_H) check_include_file(netinet/in.h PJ_HAS_NETINET_IN_H) check_include_file(netinet/ip.h PJ_HAS_NETINET_IP_H) check_include_file(netinet/tcp.h PJ_HAS_NETINET_TCP_H) check_include_file(net/if.h PJ_HAS_NET_IF_H) check_include_file(semaphore.h PJ_HAS_SEMAPHORE_H) check_include_file(setjmp.h PJ_HAS_SETJMP_H) check_include_file(stdarg.h PJ_HAS_STDARG_H) check_include_file(stddef.h PJ_HAS_STDDEF_H) check_include_file(stdio.h PJ_HAS_STDIO_H) check_include_file(stdint.h PJ_HAS_STDINT_H) check_include_file(stdlib.h PJ_HAS_STDLIB_H) check_include_file(string.h PJ_HAS_STRING_H) check_include_file(inttypes.h PJ_HAS_INTTYPES_H) check_include_file(sys/ioctl.h PJ_HAS_SYS_IOCTL_H) check_include_file(sys/select.h PJ_HAS_SYS_SELECT_H) check_include_file(sys/socket.h PJ_HAS_SYS_SOCKET_H) check_include_file(sys/time.h PJ_HAS_SYS_TIME_H) check_include_file(sys/timeb.h PJ_HAS_SYS_TIMEB_H) check_include_file(sys/types.h PJ_HAS_SYS_TYPES_H) check_include_file(sys/filio.h PJ_HAS_SYS_FILIO_H) check_include_file(sys/sockio.h PJ_HAS_SYS_SOCKIO_H) check_include_file(sys/utsname.h PJ_HAS_SYS_UTSNAME_H) check_include_file(time.h PJ_HAS_TIME_H) check_include_file(unistd.h PJ_HAS_UNISTD_H) check_include_file(execinfo.h PJ_HAS_EXECINFO_H) ``` -------------------------------- ### Determine Blocking Connect Error Value Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This configures PJ_BLOCKING_CONNECT_ERROR_VAL to either WSAEWOULDBLOCK (for Windows-like systems) or EINPROGRESS (for POSIX systems) to represent the error code for non-blocking socket connect operations that cannot complete immediately. ```cmake if(WIN32 OR CYGWIN OR MINGW) set(PJ_BLOCKING_CONNECT_ERROR_VAL WSAEWOULDBLOCK) else() set(PJ_BLOCKING_CONNECT_ERROR_VAL EINPROGRESS) endif() ``` -------------------------------- ### Detect Operating System Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt Converts the CMAKE_SYSTEM_NAME to lowercase and sets platform-specific variables like PJ_ANDROID, PJ_WIN32, PJ_DARWINOS, PJ_LINUX, PJ_BSD, PJ_RTEMS, or PJ_SUNOS. ```cmake string(TOLOWER ${CMAKE_SYSTEM_NAME} PJ_OS_NAME) if(ANDROID) set(PJ_ANDROID 1) elseif(WIN32 OR CYGWIN OR MINGW) set(PJ_WIN32 1) set(PJ_WIN32_WINNT 0x0501) set(WIN32_LEAN_AND_MEAN 1) set(NOMINMAX 1) if(CMAKE_SYSTEM_NAME MATCHES "_64-w64-mingw" OR CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64") set(PJ_WIN64 1) endif() elseif(APPLE) set(PJ_DARWINOS 1) elseif(LINUX) set(PJ_LINUX 1) elseif(BSD) set(PJ_BSD 1) else() # manual system name checks string(TOLOWER "${CMAKE_SYSTEM_NAME}" _system_name_lower) if(PJ_OS_NAME MATCHES "rtems") set(PJ_RTEMS 1) elseif(PJ_OS_NAME STREQUAL "sunos|solaris") set(PJ_SUNOS 1) endif() endif() ``` -------------------------------- ### Configure Thread Stack Allocation Source: https://github.com/pjsip/pjproject/blob/master/pjlib/CMakeLists.txt This sets PJ_THREAD_ALLOCATE_STACK based on whether the target OS is RTEMS. This flag determines if pj_thread_create() should allocate the thread's stack from a pool. ```cmake if(PJ_RTEMS) set(PJ_THREAD_ALLOCATE_STACK 1) else() set(PJ_THREAD_ALLOCATE_STACK 0) endif() ``` -------------------------------- ### Define SRTP Library Target Source: https://github.com/pjsip/pjproject/blob/master/third_party/srtp/CMakeLists.txt Defines the main SRTP library target and lists its source files, categorized by functionality. ```cmake add_library(srtp # main srtp/srtp.c # ciphers crypto/cipher/cipher.c crypto/cipher/null_cipher.c crypto/cipher/cipher_test_cases.c # hashes crypto/hash/null_auth.c crypto/hash/auth.c crypto/hash/auth_test_cases.c # replay crypto/replay/rdb.c crypto/replay/rdbx.c # math crypto/math/datatypes.c # kernel crypto/kernel/crypto_kernel.c crypto/kernel/alloc.c crypto/kernel/key.c pjlib/srtp_err.c #crypto/ust/ust.c ) ``` -------------------------------- ### Link pjmedia Dependencies Source: https://github.com/pjsip/pjproject/blob/master/pjmedia/CMakeLists.txt Specifies the libraries that the pjmedia target depends on, including public and private dependencies for features like SRTP, resampling, AEC, and video processing. ```cmake target_link_libraries(pjmedia PUBLIC # pjlib - PUBLIC to propagate PJ_AUTOCONF and other compile definitions pjlib # srtp - PUBLIC to propagate shared library dependency to consumers $<$:Pj::Dep::SRTP> PRIVATE # project pjlib-ssl pjlib-util pjnath # resampling backend $<$:Pj::Dep::Resample> $<$:SampleRate::SampleRate> $<$:Pj::Dep::Speex> $<$:SpeexDSP::SpeexDSP> # aec $<$:Pj::Dep::Speex;SpeexDSP::SpeexDSP> $<$:Pj::Dep::WebRTC> $<$:Pj::Dep::WebRTC_AEC3> # video $<$:Pj::Dep::YUV> $<$:FFMPEG::avutil> $<$:FFMPEG::swscale> $<$:FFMPEG::avcodec> $<$:FFMPEG::avformat> $<$:FFMPEG::avdevice> ) ```