[SIP Beyond VoIP] Embedding sipsimple in a MacOS application

Saúl Ibarra Corretgé saul at ag-projects.com
Mon Nov 14 09:32:28 CET 2011


Hi Mihai,

On Nov 11, 2011, at 7:14 PM, Mihai Richard wrote:

> Hello,
> 
> I’m running the sipsimple engine inside a MacOS application in a similar manner to what Blink is doing except that this application has much of the driving code written in objective-c unlike Blink client who has little C code(used only for initialization). The problem that I’m experiencing is more of  a Python embedding in C rather than a sipsimple problem but I believe that you still may be able to answer/give me a hint.
> 
> So...problem is something like this. If I start the application’s event loop using the NSApplicationMain() function and initalize sipsimple objects using the PyRun_SimpleString() I do not receive the SIPApplicationWillStart, DidStart, etc or any other notification from the NotificationCenter. On the other hand if I start the event loop using PyRun_SimpleString(“AppHelper.runEventLoop(argv=[])”) than I am able to receive all the notifications and sipsimple seems to work. However the PyRun_SimpleString() call does not exit since it holds the event loop and another call of PyRun_SimpleString inside this call of the same function crashes the application. I have tried changing PyRun_SimpleString with PyEval_CallObject() but I get the same results, application crashes for nested calls.
> 
> My question is how could I make sipsimple objects(from python code) receive notifications from NotificationCenter and have the main loop started using NSApplicationMain()(to avoid nested python embedding in c API calls)?
> 
> The python code that uses the sipsimple API works fine if it is run in the interpretor, not embedded in a C application.
> 

Did you try the approach we took on Blink? Basically there are 2 event loops: the GUI event loop and the one SIP SIMPLE SDK uses (twisted, FWIW).

If you'd run a single loop, you'll probably hog the GUI because of all the processing that happens in the Twisted thread. We have some helper functions and decorators in both Blink and sipsimple (run_in_gui_thread, run_in_twisted_thread, ASO) you may want to have a look and see if they apply to your case as well.


Regards,

--
Saúl Ibarra Corretgé
AG Projects





More information about the SIPBeyondVoIP mailing list