Ignore:
Timestamp:
Aug 7, 2006 1:22:23 PM (18 years ago)
Author:
bennylp
Message:

Added Ctrl-C handler for pjsua Windows, and added average bps in media statistic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/main.c

    r503 r660  
    2929pj_status_t app_destroy(void); 
    3030 
     31 
     32#if defined(PJ_WIN32) && PJ_WIN32!=0 
     33#include <windows.h> 
     34 
     35static pj_thread_desc handler_desc; 
     36 
     37static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) 
     38{ 
     39    pj_thread_t *thread; 
     40 
     41    switch (fdwCtrlType)  
     42    {  
     43        // Handle the CTRL+C signal.  
     44  
     45        case CTRL_C_EVENT:  
     46        case CTRL_CLOSE_EVENT:  
     47        case CTRL_BREAK_EVENT:  
     48        case CTRL_LOGOFF_EVENT:  
     49        case CTRL_SHUTDOWN_EVENT:  
     50            pj_thread_register("ctrlhandler", handler_desc, &thread); 
     51            PJ_LOG(3,(THIS_FILE, "Ctrl-C detected, quitting..")); 
     52            app_destroy(); 
     53            ExitProcess(1); 
     54            return TRUE;  
     55  
     56        default:  
     57  
     58            return FALSE;  
     59    }  
     60} 
     61 
     62static void setup_signal_handler(void) 
     63{ 
     64    SetConsoleCtrlHandler(&CtrlHandler, TRUE); 
     65} 
     66 
     67#else 
     68 
     69static void setup_signal_handler(void) 
     70{ 
     71} 
     72 
     73#endif 
     74 
    3175int main(int argc, char *argv[]) 
    3276{ 
    3377    if (app_init(argc, argv) != PJ_SUCCESS) 
    3478        return 1; 
     79 
     80    setup_signal_handler(); 
    3581 
    3682    app_main(); 
Note: See TracChangeset for help on using the changeset viewer.