Ignore:
Timestamp:
Jul 14, 2011 8:46:19 AM (13 years ago)
Author:
ming
Message:

Re #1278: NSApplication and NSAutoreleasePool management for Mac OS X

Application now needs to call pj_run_app() from its main() function and pass a pointer to the application's main function. For some examples, please refer to aviplay, pjmedia_test, and pjsua.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/test/test.c

    r3633 r3643  
    2020#include "test.h" 
    2121 
    22 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 
    23 #   include <CoreFoundation/CFRunLoop.h> 
    24 #endif 
    25  
    2622#define THIS_FILE   "test.c" 
    2723 
     
    3733 
    3834pj_pool_factory *mem; 
    39 pj_bool_t is_quit = PJ_FALSE; 
    40 pj_thread_t *thread; 
    41 pj_caching_pool caching_pool; 
    42 pj_pool_t *pool; 
     35 
    4336 
    4437void app_perror(pj_status_t status, const char *msg) 
     
    5144} 
    5245 
    53 static int test_func(void *data) 
     46int test_main(void) 
    5447{ 
    5548    int rc = 0; 
     49    pj_caching_pool caching_pool; 
     50    pj_pool_t *pool; 
     51 
     52    pj_init(); 
     53    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); 
     54    pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL); 
     55 
     56    pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 
     57    pj_log_set_level(3); 
     58 
     59    mem = &caching_pool.factory; 
     60 
     61    pjmedia_video_format_mgr_create(pool, 64, 0, NULL); 
     62    pjmedia_converter_mgr_create(pool, NULL); 
     63    pjmedia_vid_codec_mgr_create(pool, NULL); 
    5664 
    5765#if HAS_VID_PORT_TEST 
     
    6270    DO_TEST(vid_dev_test()); 
    6371#endif 
    64      
     72 
    6573#if HAS_VID_CODEC_TEST 
    6674    DO_TEST(vid_codec_test()); 
    6775#endif 
    68      
     76 
    6977#if HAS_SDP_NEG_TEST 
    7078    DO_TEST(sdp_neg_test()); 
     
    8290    DO_TEST(codec_test_vectors()); 
    8391#endif 
    84      
     92 
    8593    PJ_LOG(3,(THIS_FILE," ")); 
    86      
     94 
    8795on_return: 
    8896    if (rc != 0) { 
     
    9199        PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!")); 
    92100    } 
    93      
    94     is_quit = PJ_TRUE; 
    95     return rc; 
    96 } 
    97  
    98 int test_main(void) 
    99 { 
    100     int rc = 0; 
    101  
    102     pj_init(); 
    103     pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); 
    104     pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL); 
    105      
    106     pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 
    107     pj_log_set_level(3); 
    108  
    109     mem = &caching_pool.factory; 
    110  
    111     pjmedia_video_format_mgr_create(pool, 64, 0, NULL); 
    112     pjmedia_converter_mgr_create(pool, NULL); 
    113     pjmedia_vid_codec_mgr_create(pool, NULL); 
    114  
    115 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 
    116     { 
    117         if (pj_thread_create(pool, "test_func", test_func, NULL, 0, 0, 
    118                              &thread) == PJ_SUCCESS) { 
    119             while (!is_quit) { 
    120                 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false); 
    121             } 
    122         } 
    123         return 0; 
    124     } 
    125 #else 
    126     rc = test_func(NULL); 
    127 #endif 
    128101 
    129102    pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance()); 
Note: See TracChangeset for help on using the changeset viewer.