- Timestamp:
- Aug 27, 2010 6:46:29 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/ipjsua/Classes/ipjsuaAppDelegate.m
r3258 r3299 8 8 9 9 #import <pjlib.h> 10 #import <pjsua.h> 10 11 #import "ipjsuaAppDelegate.h" 11 12 … … 19 20 20 21 /* Sleep interval duration */ 21 #define SLEEP_INTERVAL 0.522 #define SLEEP_INTERVAL 0.5 22 23 /* Determine whether we should print the messages in the debugger 23 24 * console as well 24 25 */ 25 #define DEBUGGER_PRINT 126 #define DEBUGGER_PRINT 1 26 27 /* Whether we should show pj log messages in the text area */ 27 #define SHOW_LOG 1 28 #define PATH_LENGTH PJ_MAXPATH 28 #define SHOW_LOG 1 29 #define PATH_LENGTH PJ_MAXPATH 30 #define KEEP_ALIVE_INTERVAL 600 29 31 30 32 extern pj_bool_t app_restart; … … 35 37 ipjsuaAppDelegate *app; 36 38 37 bool app_running;38 bool thread_quit;39 bool app_running; 40 bool thread_quit; 39 41 NSMutableString *mstr; 42 pj_thread_desc a_thread_desc; 43 pj_thread_t *a_thread; 44 pjsua_call_id ccall_id; 40 45 41 46 pj_status_t app_init(int argc, char *argv[]); 42 47 pj_status_t app_main(void); 43 48 pj_status_t app_destroy(void); 49 void keepAliveFunction(int timeout); 44 50 45 51 void showMsg(const char *format, ...) … … 51 57 NSString *str = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%s", format] arguments: arg]; 52 58 #if DEBUGGER_PRINT 53 NSLog( str);59 NSLog(@"%@", str); 54 60 #endif 55 61 va_end(arg); … … 92 98 showMsg("%s", data); 93 99 } 100 101 pj_bool_t showNotification(pjsua_call_id call_id) 102 { 103 #ifdef __IPHONE_4_0 104 ccall_id = call_id; 105 106 // Create a new notification 107 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 108 UILocalNotification* alert = [[[UILocalNotification alloc] init] autorelease]; 109 if (alert) 110 { 111 alert.repeatInterval = 0; 112 alert.alertBody = @"Incoming call received..."; 113 alert.alertAction = @"Answer"; 114 115 [[UIApplication sharedApplication] presentLocalNotificationNow:alert]; 116 } 117 118 [pool release]; 119 120 return PJ_FALSE; 121 #else 122 return PJ_TRUE; 123 #endif 124 } 125 126 - (void)answer_call { 127 if (!pj_thread_is_registered()) 128 { 129 pj_thread_register("ipjsua", a_thread_desc, &a_thread); 130 } 131 pjsua_call_answer(ccall_id, 200, NULL, NULL); 132 } 133 134 #ifdef __IPHONE_4_0 135 - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { 136 [app performSelectorOnMainThread:@selector(answer_call) withObject:nil waitUntilDone:YES]; 137 } 138 139 - (void)keepAlive { 140 if (!pj_thread_is_registered()) 141 { 142 pj_thread_register("ipjsua", a_thread_desc, &a_thread); 143 } 144 keepAliveFunction(KEEP_ALIVE_INTERVAL); 145 } 146 147 - (void)applicationDidEnterBackground:(UIApplication *)application 148 { 149 [app performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES]; 150 [application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{ 151 [app performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES]; 152 }]; 153 } 154 155 #endif 94 156 95 157 - (void)start_app {
Note: See TracChangeset
for help on using the changeset viewer.