Sipek VoIP

Recent site activity

614days since
SipekSdk Project Started

About

Copyright (c) 2008 Sasa Coh

Sipek Mobile‎ > ‎

Sipek Goes Mobile - Tutorial



Here is a detailed step-by-step tutorial on building Windows mobile applications with SipekSdk and pjsip.org from a scratch. The tutorial is a result of many posts on Sipek discussion group. Many thanks to all of you who shared experiences on porting Sipek to Mobile platform, special thanks to Jonathan and Gianfranco.

The development environment tools used in tutorial:
  • VS2005 + Windows Mobile 6 SDK (standard / profesional) or
  • VS2008 + Windows Mobile 6 SDK (standard / profesional)


The first part of tutorial explains how to build the pjsip.org stack for windows mobile targets. The next step is about building SipekSdk project for Mobile devices. And finally the last step presents how to create windows mobile application using pjsip.org and SipekSdk. I hope you'll enjoy...




Build pjsip Mobile Wrapper


The Pjsip Mobile Wrapper is a "C" interface to pjsua layer of pjsip.org SIP stack just like the pjsipWrapper. The difference is that it's compiled for Windows Mobile Platform and this requires some changes in project as well in code. The result of compilation is a dynamic library pjsipDll_mobile.dll. 

Here are the steps to build pjsip sources with pjsipDll_mobile project:

Build the pjsip.org stack for Windows Mobile target platform (see the original documentation):
  1. Get the pjsip.org's SIP stack sources from SVN repository (version 0.9 or 1.0)
  2. Open <dir>\pjsip-apps\build\wince-evc4\wince_demos.vcw from Visual C++ (VS 2005)
    When asked to use existing project => answer NO
    When asked to convert the project => answer YES
  3. Make a config_site.h file in pjlib/include/pj folder (or just rename config_site_sample.h)

    Set #define's

    To activate audio for windows mobile device set the defines below into PJ_WIN32_WINCE section:

    #   define PJMEDIA_SOUND_IMPLEMENTATION PJMEDIA_SOUND_WIN32_MME_SOUND
    #   define PJMEDIA_HAS_ILBC_CODEC 0

  4. (optional) Change vsnprintf to vsprintf in <dir>\third_party\portaudio\src\common\pa_debugprint.c 

    Warning

    If your platform doesn’t have vsnprintf, you are stuck with a VERY dangerous alternative, vsprintf (with no n)
  5. Change the target platform and SDK (e.g. Windows Mobile 6.0 PC emulator and Windows Mobile 6.0 SDK) 
  6. Compile the project! 
Now add pjsipDll_mobile project:
  1. Get the sources of pjsipDll project from SipekSdk (SVN: http://sipeksdk.googlecode.com/svn/trunk/pjsipdll ) 
  2. Add windows mobile project (<dir>/build/pjsipDll_mobile.vcproj) to the solution

    Info

    Note that pjsipDll_mobile project uses different source files (ie. pjsipDll_mobile.cpp/h). That's in the first place because of problems when passing strings from managed to unmanaged code. In mobile version a wchar_t is used and converted to unicode. 

    It would be great if in the future we manage to merge these versions because of double maintanance problems. 

  3. Set the dependencies (to all projects in solution except demos and tests)
  4. Compile the project!

If everything is ok then in <pjsipDll project>/lib folder you'll find pjsipDll_mobile.dll. This is a dynamic link library ready to use in windows mobile applications.

Now we have windows mobile dynamic library that can be used in SipekSdk based mobile application. 


Build Mobile version of SipekSdk


This step is trivial. The only difference here is that you need to define conditional compilation symbol "MOBILE" in the project properties. This way SipekSdk loads pjsipDll_mobile.dll library instead of standard pjsipDll.dll. Use SipekSdk mobile project (sipeksdk_mobile.vcproj) where the "MOBILE" symbol is defined already. The sources are the same - no windowx mobile specifics in sources. 

You can download SipekSdk sources and project files at SVN: http://sipeksdk.googlecode.com/svn/trunk/SipekSdk 


Windows Mobile Application            


This tutorial focuses on Windows Mobile 6 SDK (and Windows Mobile 6 Professional Emulator). It should be the same for other targets. If not, please let me know. 

Warning

The problem is that pjsipDll_mobile.dll library cannot be added to a C# windows mobile project as a reference. And consequently it won't deploy to the device or emulator. The solution is to put it there manually.


Ok, let's rock now:
  1. Create new Visual C# / Smart Device project: File -> New -> Project: Visual C# -> Smart Device -> Windows Mobile 6 Standard (select other if you want)
  2. Add SipekSdk_mobile.dll (mobile version) to a project references
  3. Make simple smart device GUI (see the example mobile project)
  4. Apply the SipekSdk library just like in the standard windows application (instant softphone tutorial)
  5. Compile and deploy!

    Warning

    At this point an exception could occur: cannot invoke P/INVOKE DLL
    This is due to missing or incompatible pjsipDll_mobile.dll! 

  6. To solve this => Copy the pjsipDll_mobile.dll to the device's application folder  (<program files\sipekmobile\>) by hand! 

    Hint

    For some reason Visual Studio do not allow to add the pjsipDll_mobile.dll to the project references. 
    You have to do it by hand using "Microsoft Visual Studio 2005" -> "Visual Studio Remote Tools" -> "Remote File Viewer"

  7. Deploy again! It should work now! 
Congratulations!


Conclusion

Above are the basic steps only. For details please download the complete sources and project from example project at: http://sipekapps.googlecode.com/svn/trunk/MobileExample 

See screenshots of registration and calling forms:

 




Comments (1)

Sasa Coh - 15 Jan 2009 12:14

Info: Problems with poor sound quality (audio breakups) on HTC Touch device with Windows Mobile 6 due to high CPU load. Set the clock rate to 8000. In pjsipDll_mobile.cpp:

app_config.media_cfg.clock_rate = 8000;