本文记录如何在windows下编译pjsip并支持视频,包括pjsua2的python模块。

1,安装mingw

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

2,在mingw中安装:msys-base,mingw32-gcc,mingw32-gcc-g++和mingw32-libz

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

把mingw的bin目录(如C:\MinGW\bin)添加到系统环境变量path

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

3,解压pjsip2.3.0,在pjsip目录下(如D:\pjproject-2.3\pjlib\include\pj)创建config_site.h,添加

  1. #define PJMEDIA_HAS_VIDEO 1
修改D:\pjproject-2.3\pjsip\src\pjsua2-test\main.cpp,添加

  1. //添加下面一行
  2. #include "SDL.h"

修改D:\pjproject-2.3\pjsip-apps\src\samples\pjsua2_demo.cpp,添加并修改

  1. //添加下面一行
  2. #include "SDL.h"

  1. //int main()
  2. int main(int argc, char *argv[])

4,安装sdl2
从sdl网站https://www.libsdl.org/download-2.0.php下载Development Libraries:SDL2-devel-2.0.3-mingw.tar.gz
将子目录i686-w64-mingw32解压到D:\video\目录下,并将附件中的SDL_platform.h覆盖include/SDL2下的原文件
将D:\video\i686-w64-mingw32\bin添加到系统环境变量path

5,安装ffmpeg1.2
从zeranoe ffmpeg(https://ffmpeg.zeranoe.com/blog/?p=178)下载ffmpeg的windows版本:FFmpeg 1.2 Win32 SharedFFmpeg 1.2 Win32 Dev解压到D:\video\目录下
将附件中pkgconfig中的.pc文件复制到D:\video\ffmpeg-1.2-win32-dev\lib\pkgconfig,修改.pc文件

  1. prefix=/video/ffmpeg-1.2-win32-dev/
将D:\video\ffmpeg-1.2-win32-shared\bin添加到系统环境变量path

6,安装pkg-config
从GTK+ for Windows下载GLib DLLpkg-config.exe,解压libglib-2.0-0.dll和pkg-config.exe到C:\MinGW\bin,将libintl-8.dll复制另命名intl.dll

7,创建msys目录下的fstab文件(如C:\MinGW\msys\1.0\etc),添加内容:如d:/pjproject-2.3 /pjsip和d:/video /video

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

8,启动msys.bat

  1. cd /pjsip
  2. export PKG_CONFIG_PATH=/video/ffmpeg-1.2-win32-dev/lib/pkgconfig
  3. ./configure CFLAGS="-I/video/i686-w64-mingw32/include/SDL2" LDFLAGS="-L/video/i686-w64-mingw32/lib"
  4. make dep
  5. make

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

9,安装pjsua2
安装python2.7.7

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

将python目录(如C:\Python27)添加到系统环境变量path

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

下载swig,将swig目录(如D:\swigwin-3.0.2)添加到系统环境变量path

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP


  1. cd /pjsip/pjsip-apps/src/swig
  2. make
  3. make install

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

10,测试安装是否成功
在cmd里启动python,输入:

  1. import pjsua2

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHP

注1:修改完系统环境变量path后,要重新打开msys
注2:相关下载
mingw: http://sourceforge.net/projects/mingw/files/
pjsip: http://www.pjsip.org/release/2.3/pjproject-2.3.zip
python: https://www.python.org/ftp/python/2.7.7/python-2.7.7.msi
swig: http://prdownloads.sourceforge.net/swig/swigwin-3.0.2.zip
sdl: https://www.libsdl.org/release/SDL2-devel-2.0.3-mingw.tar.gz
ffmpeg: http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-1.2-win32-shared.7zhttp://ffmpeg.zeranoe.com/builds/win32/dev/ffmpeg-1.2-win32-dev.7z
pkg-config: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.23-3_win32.zip
glib dll: http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28/glib_2.28.1-1_win32.zip

complie pjsip with video support and pjsua2 on windows with mingw-LMLPHPpkgconfig-ffmpeg.zip
complie pjsip with video support and pjsua2 on windows with mingw-LMLPHPSDL_platform.zip

10-03 22:35