1 | | On Mac OS X, application needs to initialize an autorelease memory pool, event loop management, and multi-threading environment if it needs to use Cocoa framework (currently used by qt_dev and sdl_dev). |
| 1 | Some video devices implementation (in pjmedia-videodev) assumes that the application has been initialized in certain way in order for it to work. For example, the SDL and !QuickTime video device implementation on Mac OS X requires NSApplication and NSAutoreleasePool to be present in the application. |
| 2 | |
| 3 | That normally is not a problem if the application is GUI application created with IDE such as XCode, since the IDE will create those for us. But for application created manually, such as console apps that are common in our samples, these objects have to be created manually. |
| 4 | |
| 5 | This ticket implements a generic way to initialize system specific settings to the application. This new API in {{{pj/os.h}}} is proposed: |
| 6 | |
| 7 | {{{ |
| 8 | /* Type for main function. */ |
| 9 | typedef int (*pj_main_func_ptr)(int argc, char *argv[]); |
| 10 | |
| 11 | /** |
| 12 | * Run the application. This function has to be called in the main thread |
| 13 | * and after doing the necessary initialization according to the flags |
| 14 | * provided, it will call main_func() function. |
| 15 | * |
| 16 | * @param main_func Application's main function. |
| 17 | * @param argc Number of arguments from the main() function, which |
| 18 | * will be passed to main_func() function. |
| 19 | * @param argv The arguments from the main() function, which will |
| 20 | * be passed to main_func() function. |
| 21 | * @param flags Flags for application execution, currently must be 0. |
| 22 | * |
| 23 | * @return main_func()'s return value. |
| 24 | */ |
| 25 | int pj_run_app(pj_main_func_ptr main_func, int argc, char *argv[], |
| 26 | unsigned flags); |
| 27 | }}} |
| 28 | |
| 29 | Console apps need to call the above {{{pj_run_app()}}} API, passing it's ''main'' routine as the argument. |
| 30 | |