Hello all,
Long time user first time caller. Nice to meet you all!
I'm trying to get pjsip to work on Windows. I've compiled pjsip
into my program that I'm writing in an msys2/mingw environment
(64-bit). It compiles fine. However, when I run it in my program
I'm getting an assertion
// Line 49 of ../src/pj/sock_select.c
sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)
Every time I run the program.
When I do some digging people talk about increasing
PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the
function before the asserts to see what the sizes are:
// My PJ_FD_ZERO variant
PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp)
{
printf( "PJ_IOQUEUE_MAX_HANDLES: %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: %I64d\n", PJ_IOQUEUE_MAX_HANDLES, sizeof(pj_fd_set_t), sizeof(pj_sock_t), sizeof(fd_set) );
PJ_CHECK_STACK();
pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));
FD_ZERO(PART_FDSET(fdsetp));
PART_COUNT(fdsetp) = 0;
}
The program will output something like this:
10:27:43.477 os_core_win32.c !pjlib 2.9 for win32 initialized
10:27:43.507 sip_endpoint.c .Creating endpoint instance...
PJ_IOQUEUE_MAX_HANDLES: 16384, pj_fd_set_t: 65552, pj_sock_t: 4, fd_set: 131080
However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of
pj_fd_set_t increases as it should but! the
sizeof(fd_set) also becomes slight less than DOUBLE whatever
sizeof(pj_fd_set_t) is! The winsock guide says that I cannot set
the size of fd_set so I am very confused how the size is getting
set! I don't see anywhere in the pjsip code that this is being
set.
So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle.
How can I fix this so my code will stop asserting?
The bash script that I ran to configure pjsip
#!/bin/bash
JOPT=1
DEBUG=false
BUILD_ALL=true
CLEAN_BEFORE_BUILD=false
TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am Makefile.in"
while getopts ":pdj:o:c" opt; do
case $opt in
j)
JOPT="$OPTARG"
;;
c)
echo "Clean before build is set."
CLEAN_BEFORE_BUILD=true;
;;
d)
DEBUG=true
;;
o)
IFS=', ' read -r -a BUILD_OPTS <<< "${OPTARG}"
BUILD_ALL=false
for option in "${BUILD_OPTS[@]}" ; do
# Set individual
case $option in
pjsip)
BUILD_PJSIP=true;
;;
*)
echo "Unknown build option ${option}"
exit
esac
done
;;
\?)
echo "Invalid option: -${OPTARG}" >&2
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument." >&2
exit 1
;;
esac
done
# Make the out
mkdir out
OUT_PREFIX="$( pwd )/out"
export PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
if [ "$DEBUG" = true ] ; then
MAKEFLAGS="-g -O0"
else
MAKEFLAGS="-O2"
fi
# Main directory
LIB_DIRECTORY="$(pwd)/lib"
# Descend
cd "${LIB_DIRECTORY}"
pwd
# pjsip
cd "${LIB_DIRECTORY}/pjsip"
if [ "${BUILD_ALL}" = true ] || [ "${BUILD_PJSIP}" = true ] ; then
eval $TOUCH_COMMAND
./configure CFLAGS="${MAKEFLAGS} -I${OUT_PREFIX}/include" CXXFLAGS="${MAKEFLAGS}" LDFLAGS="-L${OUT_PREFIX}/lib" \
--prefix="${OUT_PREFIX}" \
--disable-openh264 \
--disable-v4l2 \
--disable-ffmpeg \
--enable-libsamplerate \
--disable-video \
--enable-shared \
--disable-static \
--disable-libyuv \
--with-external-speex \
--with-gnutls \
|| exit
if [ "${CLEAN_BEFORE_BUILD}" = true ] ; then
make clean
fi
# Without this it breaks on msys2
make -j $JOPT dep || exit
# Make the actual
make -j $JOPT || exit
# Note, had issue with writing to //c/.../pkgconfig/libproject.pc
make install || exit
fi
--
Michael A. Leonetti
As warm as green tea