How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf...

20
How I cross-compiled Kurento Media Server for Windows Kyrylo Polezhaiev

Transcript of How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf...

Page 1: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

HowIcross-compiledKurentoMediaServerforWindows

KyryloPolezhaiev

Page 2: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Alotofmodulesanddependencies

• kms-core• kurento-media-server• kurento-filters• kurento-elements• kms-jsonrpc• jsoncpp

• gstreamer-1.5• gst-plugins-base-1.5• gst-plugins-good-1.5• gst-plugins-bad-1.5• gst-plugins-ugly-1.5• openwebrtc-gst-plugins-1.5

• libiconv• boost• libffi• Glib,Glibmm• gettext• gcc• Libxml2• usrsctp• libevent

• libnice• SQLite• libsigc++• libopus• OpenCV• libsoup• OpenSSL• winpthreads• libvpx

Page 3: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Ideas

• Tocross-compileKMSfromFedorausingMinGWcompiler• BuildprototypeusinghandmadeMakefilesthenuseCMake

Page 4: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Pros.ofcross-compilingusingFedora

• WehaveLinuxenvironmentandpackagemanager• Fedorahasalotofready-to-usepackagesprebuiltwithMinGW

sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2 mingw32-orc mingw32-libtheora mingw32-libvorbis mingw32-opus mingw32-libsigc++20 mingw32-glibmm24 yasm mingw32-openssl indent astyle

Page 5: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Alotofmodulesanddependencies

• kms-core• kurento-media-server• kurento-filters• kurento-elements• kms-jsonrpc• jsoncpp

• gstreamer-1.5• gst-plugins-base-1.5• gst-plugins-good-1.5• gst-plugins-bad-1.5• gst-plugins-ugly-1.5• openwebrtc-gst-plugins-1.5

• libiconv• boost• libffi• Glib,Glibmm• gettext• gcc• Libxml2• usrsctp• libevent

• libnice• SQLite• libsigc++• libopus• OpenCV• libsoup• OpenSSL• winpthreads• libvpx

Page 6: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Alotofmodulesanddependencies

• kms-core• kurento-media-server• kurento-filters• kurento-elements• kms-jsonrpc• jsoncpp

• gstreamer-1.5• gst-plugins-base-1.5• gst-plugins-good-1.5• gst-plugins-bad-1.5• gst-plugins-ugly-1.5• openwebrtc-gst-plugins-1.5

• libiconv• boost• libffi• Glib,Glibmm• gettext• gcc• Libxml2• usrsctp• libevent

• libnice• SQLite• libsigc++• libopus• OpenCV• libsoup• OpenSSL• winpthreads• libvpx

Page 7: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

BuildusinghandmadeMakefiles

• IwrotehugeMakefilesmanually• UsedvanillaGStreamer

Page 8: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

TweaksIhadtodo:

• libuuid (uuid_generate,uuid_unparse)→ rpcrt4(CoCreateGuid,UuidToStringA,RpcStringFree)• ushort,uint → unsignedshort,unsignedorguint etc.• <sys/socket.h>,<arpa/inet.h>→ <ws2tcpip.h>,<winsock2.h>• Linkagainst-lws2_32-liphlpapi• Use–no-undefinedflag,don’tuse–dland-fPIC• %ld,%zd,%hhx → G_GUINT64_FORMAT,G_GSIZE_FORMAT• Define-DWIN32_LEAN_AND_MEAN=1

Page 9: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

StandardCMake+Autotoolsway

• ForAutotool-basedcases,simpleautogen.sh +mingw32-configure+make+makeinstallscenarioworks• Forlibvpx thismagicworks:eval `rpm --eval %{mingw32_env}`export AS=yasm./configure \--target=x86-win32-gcc \--prefix=/usr/i686-w64-mingw32/sys-root/mingw/

Page 10: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

StandardCMake+Autotoolsway

• ForCMake-controlledKMSmodules:

mingw32-cmake -DCMAKE_BUILD_TYPE=Release \-DCMAKE_MODULE_PATH=\/usr/i686-w64-mingw32/sys-root/mingw/share/cmake-3.5/Modules/ \-DCMAKE_INSTALL_PREFIX=\/usr/i686-w64-mingw32/sys-root/mingw \-DKURENTO_MODULES_DIR=\/usr/i686-w64-mingw32/sys-root/mingw/share/kurento/modules/ \<path>

Page 11: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

TweakstoCMakeFiles

• ExplicitlydefinedsomelibrariesSTATIC• Explicitlylink*endpointswith-lkmssdpagent -lgstsdp-1.5.dll• Replacedlinkingorderforsomelibs

Page 12: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

PrepareDistro

• Aftereverythingisbuild,it’sinstalledin/usr/i686-w64-mingw32/sys-root/mingw/

• Takekurento-media-server.exe andsomeof.dlls tobin/• PutneededGStreamerpluginsintolib/gstreamer-1.5/• PutKurentomoduless intolib/kurento/modules/• Put configurationfilesintoetc/kurento/andetc/kurento/modules/kurento

Page 13: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2
Page 14: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

DebugProblems

• CannottestWinsock2onWine• Difficulttouse&navigatesourcesonWindows

Page 15: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Debug

• Takegdbserver.exe providedbyFedoraMinGWpackageandputintoWindowsmachinenearkurento-media-server.exe• MakesureWindowsfirewallallowsgdbserver andKMSlistenports.• Rungdbserver.exe likethat:gdbserver.exe :4444 kurento-media-server.exe

• Connecttoitviagdb,specifyingsomethinglike:set target-file-system-kind dos-based

target remote 172.16.211.244:4444

Page 16: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Don’tselecttextinConsoleWindow!J

Page 17: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2
Page 18: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2
Page 19: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Todo:

• MakeKMSworkasstandardWindowsService• Fixrandomsequencesgeneration• Fixpaths-relatedproblems

Page 20: How I cross-compiled Kurento Media Server for Windows · sudo dnf install autoconf mingw32-filesystem cmake mingw32-gcc-c++ maven mingw32-boost gettext-devel bison flex mingw32-glib2

Thankyou!

Youcancomecloserandtakealookhowitworks